You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/storage/warehouses/redshift-useful-sql.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,9 @@ You can use SQL queries for the following tasks:
17
17
18
18
## Tracking events
19
19
20
-
The track allows you to record any actions your users perform. A track call takes three parameters: the userId, the event, and any optional properties.
20
+
The Track call allows you to record any actions your users perform. A Track call takes three parameters: the userId, the event, and any optional properties.
Each track call is stored as a distinct row in a single Redshift table called `tracks`. To get a table of your completed orders, you can run the following query:
44
+
Each Track call is stored as a distinct row in a single Redshift table called `tracks`. To get a table of your completed orders, you can run the following query:
45
45
46
46
```sql
47
47
select*
@@ -53,8 +53,8 @@ That SQL query returns a table that looks like this:
53
53
54
54

55
55
56
-
But why are there columns in the table that weren't a part of the track call, like `event_id`?
57
-
This is because the track method (for client-side libraries) includes additional properties of the event, like `event_id`, `sent_at`, and `user_id`!
56
+
But why are there columns in the table that weren't a part of the Track call, like `event_id`?
57
+
This is because the Track method (for client-side libraries) includes additional properties of the event, like `event_id`, `sent_at`, and `user_id`!
58
58
59
59
### Grouping events by day
60
60
If you want to know how many orders were completed over a span of time, you can use the `date()` and `count` function with the `sent_at` timestamp:
@@ -139,15 +139,15 @@ SELECT *,
139
139
140
140
### Historical traits
141
141
142
-
The `identify` method ties user attributes to a `userId`.
142
+
The Identify method ties user attributes to a `userId`.
As these user traits change over time, you can continue calling the identify method to update their changes. With this query, you can update Bob’s account plan to “Premium”.
150
+
As these user traits change over time, you can continue calling the Identify method to update their changes. With this query, you can update Bob’s account plan to “Premium”.
Each identify call is stored in a single Redshift table called `identifies`. To see how a user's plan changes over time, you can run the following query:
159
+
Each Identify call is stored in a single Redshift table called `identifies`. To see how a user's plan changes over time, you can run the following query:
160
160
161
161
```sql
162
162
select email, plan, sent_at
@@ -173,7 +173,7 @@ This SQL query returns a table of Bob's account information, with each entry rep
173
173
174
174
If you want to see what your users looked like at a previous point in time, you can find that data in the `identifies` table. To get this table for your users, replace ‘initech’ in the SQL query with your source slug.
175
175
176
-
But what if you only want to see the most recent state of the user? Luckily, you can convert the `identifies` table into a distinct users table by taking the most recent identify call for each account.
176
+
But what if you only want to see the most recent state of the user? Luckily, you can convert the `identifies` table into a distinct users table by taking the most recent Identify call for each account.
177
177
178
178
### Convert the identifies table into a users table
0 commit comments