List the total slots booked per facility

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.

Expected Results

facidTotal Slots
01320
11278
21209
3830
41404
5228
61104
7908
8911

Your Answer

Your Results

Loading database...

Answers and Discussion

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.