Skip to content

SQL Practice 9

1. 문제 [[object Object]]

환자가 거주하는 도시를 기준으로, province_id가 'NS'인 도시를 표시하시오.

patient_idfirst_namelast_namegenderbirth_datecityprovince_idallergiesheightweight
301RicardoAndrewsM1987-07-21HamiltonONNULL177112
302PaulVondopoulosM2010-05-22BrantfordONNULL10736
303AgnesParkinsonF1975-01-11HamiltonONSulfa Drugs15847
304JeffreyPascoeM1957-05-12HamiltonONSulfa17484
305AmaneFluteF2006-03-27HamiltonONNULL13048
306MattFranchettiM2007-09-25BurlingtonONMilk15760

2. 정답

SELECT DISTINCT(city) AS unique_cities
FROM patients
WHERE province_id = 'NS';

3. 다른 정답

SELECT city
FROM patients
GROUP BY city
HAVING province_id = 'NS';

4. 결과

unique_cities
Hamilton
Brantford
Burlington