Precisely wants to analyze user activity across its data quality and location intelligence products. Write a PostgreSQL query that reports the first and last valid interaction for every user, including users who have no valid event records.
A valid interaction must have a non-null event_type. If multiple events have the same timestamp, use the lowest event_id as the deterministic tie-breaker.
users, including users without valid interactions.user_id ascending.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique user identifier |
| display_name | VARCHAR(100) | User's display name |
| Column | Type | Description |
|---|---|---|
| event_idPK | INTEGER | Unique event identifier |
| user_id | INTEGER | User associated with the event |
| occurred_at | TIMESTAMPTZ | Timestamp when the interaction occurred |
| event_type | VARCHAR(50) | Type of interaction |
| source | VARCHAR(50) | Application or channel source |