-
-
Save codecademydev/a1b7f2db2cb1c8d3742e9159073ebbbc to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM panels | |
WHERE ID = 'ID'; | |
UPDATE patients | |
SET Status = "active" | |
WHERE ID = 7; | |
CREATE TABLE inactive_patients | |
AS SELECT * | |
FROM patients | |
WHERE Status = "inactive"; | |
DELETE FROM patients | |
WHERE status = "inactive"; | |
ALTER TABLE patients | |
RENAME TO active_patients; | |
WITH total_active AS ( | |
SELECT COUNT(ID) AS 'active' | |
FROM active_patients | |
), | |
total_inactive AS ( | |
SELECT COUNT(ID) AS 'inactive' | |
FROM inactive_patients | |
), | |
total_patients AS ( | |
SELECT total_active.active + total_inactive.inactive AS 'total' | |
FROM total_active, total_inactive | |
) | |
SELECT | |
(total_active.active*100 / total_patients.total) AS 'percent_active', | |
(total_inactive.inactive*100 / total_patients.total) AS 'percent_inactive' | |
FROM total_active, total_inactive, total_patients; | |
select * | |
from active_patients | |
order by ID desc | |
limit 2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment