Views and purchases per product

Views and purchases per product

From the events table (columns product_id, event_type), count for each product_id the number of 'view' events and 'purchase' events. Return product_id, views, purchases. Sort by product_id ascending.

Expected output sample

product_idviewspurchases
121
221
331
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid