1.3 KiB
1.3 KiB
- List the names of patients who are at least fifty years old. Your query should always generate a list in which the names are sorted in alphabetical order. The ordering must not depend upon the order in which you entered data into your database.
SELECT patient_name
FROM patient
WHERE age >= 50
ORDER BY patient_name;
- List the name of each type of organ, together with the total number of donations of that type of organ.
SELECT organ_type, COUNT( organ_type )
FROM organ
INNER JOIN operation ON operation.organ_id = organ.organ_id
GROUP BY organ_type;
- List the identifiers of hospitals where a transplant has been performed, together with the number of transplant operations at the hospital.
SELECT hospital_id, COUNT( hospital_id )
FROM transplant_unit
INNER JOIN operation ON transplant_unit.unit_id = operation.unit_id
GROUP BY hospital_id;
- Output the age of the oldest person who has donated in a hospital in Manchester.
SELECT age
FROM donor
WHERE donor_id IN (
SELECT donor_id
FROM operation
WHERE unit_id IN (
SELECT unit_id
FROM transplant_unit
WHERE hospital_id IN (
SELECT hospital_id
FROM hospital
WHERE city LIKE '%Manchester%'
)
)
);