|
1 | 1 | ---
|
2 | 2 | title: Useful SQL Queries for Redshift
|
3 | 3 | ---
|
4 |
| -Below you'll find a library of some of the most useful SQL queries customers use in their Redshift warehouses. You can run these right in your Redshift instance with little to no modification. |
| 4 | +Below you'll find a library of some of the most useful SQL queries customers use in their Redshift warehouses. You can run these right in your Redshift instance with little to no modification. |
| 5 | + |
| 6 | +You can use SQL queries for the following tasks: |
| 7 | +- [Tracking events](#tracking-events) |
| 8 | +- [Defining sessions](#defining-sessions) |
| 9 | +- [Identifying users](#identifying-users) |
| 10 | +- [Groups to accounts](#groups-to-accounts) |
5 | 11 |
|
6 | 12 | > note " "
|
7 | 13 | > If you're looking for SQL queries for warehouses other than Redshift, check out some of Segment's [Analyzing with SQL guides](/docs/connections/storage/warehouses/index/#analyzing-with-sql).
|
@@ -42,13 +48,7 @@ where event = 'completed_order'
|
42 | 48 |
|
43 | 49 | That SQL query returns a table that looks like this:
|
44 | 50 |
|
45 |
| -| event | event_id | user_id | sent_at | item | color | size | payment | |
46 |
| -| --------------- | -------- | ---------- | ------------------- | ----- | ------ | ------ | ----------- | |
47 |
| -| completed_order | jrse3pyf | BQ9R7u4NA9 | 2021-12-09 03:50:00 | pants | blue | 32x33 | credit card | |
48 |
| -| completed_order | cxntjkc7 | TQ9D7x4NA4 | 2021-12-09 02:50:01 | pants | green | 31x33 | credit card | |
49 |
| -| completed_order | xjuvaely | APR97u8NB9 | 2021-12-09 01:50:39 | shirt | red | Medium | credit card | |
50 |
| -| completed_order | rft31ial | ly3jaeillp | 2021-12-09 08:50:13 | shirt | yellow | Large | credit card | |
51 |
| -| completed_order | k8bhgc6h | X9G5Qg0tha | 2021-12-09 07:20:19 | shirt | yellow | Small | paypal | |
| 51 | + |
52 | 52 |
|
53 | 53 | But why are there columns in the table that weren't a part of the track call, like `event_id`?
|
54 | 54 | This is because the track method (for client-side libraries) automatically includes additional properties of the event, like `event_id`, `sent_at`, and `user_id`!
|
@@ -259,7 +259,7 @@ The `group` method ties a user to a group. It also lets you record custom traits
|
259 | 259 | Here’s what a basic `group` call looks like:
|
260 | 260 |
|
261 | 261 | ```javascript
|
262 |
| -analytics.group'0e8c78ea9d97a7b8185e8632', { |
| 262 | +analytics.group('0e8c78ea9d97a7b8185e8632', { |
263 | 263 | name: 'Initech',
|
264 | 264 | industry: 'Technology',
|
265 | 265 | employees: 329,
|
|
0 commit comments