Skip to content

Commit abf12aa

Browse files
authored
Merge pull request #6790 from segmentio/estgc-patch-2
Add Profiles Sync Sample Query
2 parents f867dff + e600c27 commit abf12aa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/unify/profiles-sync/sample-queries.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,22 @@ GROUP BY 1
123123
SELECT * FROM ps_materialize.profile_traits WHERE merged_to IS NULL
124124
```
125125

126+
### Pull the latest subscription status set for every profile identifier in the space
127+
128+
Provides the latest subscription status set for all identifiers in the space. This query will not include identifiers that have no subscription status ever set.
129+
130+
```sql
131+
SELECT evt1.user_id, evt1.channel, evt1._id id, evt1.status, evt1.received_at
132+
FROM ps_segment.CHANNEL_SUBSCRIPTION_UPDATED evt1
133+
JOIN (
134+
SELECT _id, MAX(received_at) AS max_received_at
135+
FROM ps_segment.CHANNEL_SUBSCRIPTION_UPDATED
136+
GROUP BY _id
137+
) evt2
138+
ON evt1._id = evt2._id AND evt1.received_at = evt2.max_received_at
139+
ORDER BY 1
140+
```
141+
126142
### Show all pages visited by a user
127143

128144
To get complete user histories, join event tables to the identity graph and aggregate or filter with `id_graph.canonical_segment_id`:

0 commit comments

Comments
 (0)