Shopify wants a monthly view of merchant sales and admin engagement. Write a PostgreSQL query that combines Shopify sales records with admin activity logs without allowing multiple log rows to duplicate sales.
Not engaged; label merchants with at least one session Engaged.| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| merchant_id | INT | Shopify merchant identifier |
| occurred_at | TIMESTAMP | Timestamp when the sale occurred |
| amount | DECIMAL(12,2) | Sale amount in the merchant billing currency |
| status | VARCHAR(20) | Sale processing status |
| Column | Type | Description |
|---|---|---|
| log_idPK | INT | Unique log identifier |
| merchant_id | INT | Shopify merchant identifier |
| logged_at | TIMESTAMP | Timestamp when the event was logged |
| event_type | VARCHAR(30) | Type of merchant activity event |
| session_id | VARCHAR(40) | Browser or application session identifier |