Return the customer's last purchase
Last updated
Last updated
Navigate to the Query Editor.
2. Grab the customer's last purchase:
The first part of the query is to return the customerβs last purchase. We can do this by querying the CustomerPurchaseActivities
collection and ordering the _event_time
in descending order. Weβll need to return the results for an _id
. To do this, weβll create a parameter, so we can put any _id
we want.
Major SQL code highlights:
On line 8, youβll notice there is a :userid
. This is the parameter weβll create.
3. Create the parameter:
Navigate to the parameters tab and add the parameter with these details:
4. Create the parameter with these details:
Parameter name: userid
Type: string
Value: 2
4. Run the query! If you donβt see results, itβs because the customer hasnβt made a purchase. Change the :userid
to a new string to see if the results are not null.
NOTE: You can find us on the Rockset Community if you have questions or comments about the workshop.