-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path032.sql
More file actions
24 lines (19 loc) · 674 Bytes
/
032.sql
File metadata and controls
24 lines (19 loc) · 674 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
/* Q: Show all of the days of the month (1-31) and how many admission_dates occurred on that day. Sort by the day with most admissions to least admissions.
Table Info: admissions
+----------------------+----------+
| Column Name | Type |
+----------------------+----------+
| patient_id | INT |
| admission_date | DATE |
| discharge_date | DATE |
| diagnosis | TEXT |
| attending_doctor_id | INT |
+----------------------+----------+
*/
-- SOLUTION:
select
day(admission_date) as day_number,
count(*) as number_of_admissions
from admissions
group by day_number
order by number_of_admissions desc;