Sum(case when attribute is true) Unions Hard SQL using window functions Python leetcode Easy
Use the provided entity and event tables. Combine the two event sources, remove exact duplicate records, and analyze events from January through March 2025.
entity_id, entity_name, month_start, event count, true-attribute count, prior-month true count, cumulative true count, and rank by monthly true countentity_id, then month_start| Column | Type | Description |
|---|---|---|
| entity_idPK | INT | Unique entity identifier |
| entity_name | VARCHAR(100) | Entity display name |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event identifier within the source |
| entity_id | INT | Referenced entity |
| event_ts | TIMESTAMP | Event timestamp |
| attribute_is_true | BOOLEAN | Whether the event attribute is explicitly true |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event identifier within the source |
| entity_id | INT | Referenced entity |
| event_ts | TIMESTAMP | Event timestamp |
| attribute_is_true | BOOLEAN | Whether the event attribute is explicitly true |