Problem Sets + Solutions for computer science topics
SELECT first_name, last_name, gender
FROM patients
WHERE gender = 'M';
SELECT first_name, last_name
FROM patients
WHERE allergies IS NULL;
SELECT first_name
FROM patients
WHERE first_name LIKE 'C%';
SELECT first_name, last_name
FROM patients
WHERE weight BETWEEN 100 AND 120;
UPDATE patients
SET allergies = 'NKA'
WHERE allergies IS NULL;
SELECT CONCAT(first_name, " ", last_name) AS full_name
FROM patients;
SELECT first_name, last_name, province_name
FROM patients JOIN province_names
ON patients.province_id = province_names.province_id;
SELECT COUNT(*)
FROM patients
WHERE YEAR(birth_date) = 2010;
SELECT first_name, last_name, height
FROM patients
WHERE height = (SELECT MAX(height) FROM patients);
SELECT * FROM patients
WHERE patient_id IN (1, 45, 534, 879, 1000);
SELECT COUNT(*) FROM admissions;
SELECT * FROM admissions
WHERE admission_date = discharge_date;
SELECT patient_id, COUNT(*)
FROM admissions
WHERE patient_id = 579;
SELECT distinct(city)
FROM patients
WHERE province_id = 'NS';
SELECT first_name, last_name, birth_date
FROM patients
WHERE height > 160 AND weight > 70;
SELECT first_name, last_name, allergies
FROM patients
WHERE allergies IS NOT NULL
AND city = 'Hamilton';
SELECT first_name, last_name, allergies
FROM patients
WHERE allergies IS NOT NULL
AND city = 'Hamilton';