Question

Produce a list of the total number of slots booked per facility. For now, just produce an output table consisting of facility id and slots, sorted by facility id.
Schema reminder
DB schema

Expected Results

facid Total Slots
0 1320
1 1278
2 1209
3 830
4 1404
5 228
6 1104
7 908
8 911

Your Answer Hint Help Save Run Query

 

Answers and Discussion Show

select facid, sum(slots) as "Total Slots"
	from cd.bookings
	group by facid
order by facid;          

Other than the fact that we've introduced the SUM aggregate function, there's not a great deal to say about this exercise. For each distinct facility id, the SUM function adds together everything in the slots column.

For this one you'll need to check out the SUM aggregate function.

Keyboard shortcuts:


Other hints: