Two counts in one query
CASE WHEN turns a condition into a value. count() skips NULL, so a CASE with no ELSE counts only the rows that match.
task
In one query, count the bookings of facility 1 and of facility 3, as two columns.
Run a query to see rows here.
Run EXPLAIN on the statement under the cursor: Plan tab, button Explain.
No tables yet.
CASE WHEN turns a condition into a value. count() skips NULL, so a CASE with no ELSE counts only the rows that match.
In one query, count the bookings of facility 1 and of facility 3, as two columns.