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.