Skip to content

Instantly share code, notes, and snippets.

@JerryNixon
Last active November 19, 2021 17:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JerryNixon/d7052ef53feef964812bc83c206f107b to your computer and use it in GitHub Desktop.
Save JerryNixon/d7052ef53feef964812bc83c206f107b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JerryNixon
Copy link
Author

JerryNixon commented Jun 4, 2021

For a given customer's purchase history what products do you recommend?

SELECT 
	  customer.Name AS CUSTOMER
	, demo.Name AS DEMOGRAPHIC
	, product.Name AS BECAUSE_OF_PURCHASE
	, recommendation.Name AS WE_RECOMMEND_PRODUCT
FROM Customer AS customer
	, is_in
	, Demographic AS demo
	, purchased
	, Product AS product
	, recommends
	, Product AS recommendation
WHERE MATCH(demo<-(is_in)-customer-(purchased)->product-(recommends)->recommendation)
AND recommends.DemographicId = demo.Id
AND customer.Id in (13)
ORDER BY 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment