#782

Show three per-user counters in one row

An analytics dashboard shows three numbers per user in a single row: how many views, how many purchases, and how many refunds they made. Without conditional aggregates you'd run three separate queries and stitch them together. For every user, compute in one query the count of events of type view, purchase, and refund separately. Sort by user id.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.

viewsrefundsuser_idpurchases
2012
3020
1131

Your query result will appear here