-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path025.sql
More file actions
30 lines (25 loc) · 671 Bytes
/
025.sql
File metadata and controls
30 lines (25 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Q: Show the city and the total number of patients in the city.
Order from most to least patients and then by city name ascending.
Table Info: patients
+--------------+----------+
| Column Name | Type |
+--------------+----------+
| patient_id | INT |
| first_name | TEXT |
| last_name | TEXT |
| gender | CHAR(1) |
| birth_date | DATE |
| city | TEXT |
| province_id | CHAR(2) |
| allergies | TEXT |
| height | INT |
| weight | INT |
+--------------+----------+
*/
-- SOLUTION:
select city, count(*) as num_patients
from patients
group by city
order by
num_patients desc,
city asc;