Skip to content

Instantly share code, notes, and snippets.

@nfarah86
Last active February 24, 2021 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfarah86/0812f33abe359072093d88fde5a893a8 to your computer and use it in GitHub Desktop.
Save nfarah86/0812f33abe359072093d88fde5a893a8 to your computer and use it in GitHub Desktop.
Promo codes being used in certain regions of the U.S.
SELECT
oi.PromoID,
pc.PromoDescription,
ca.CustomerRegion,
COUNT(*) as totalPromoUsed
FROM
commons.orderItem oi
join commons.customerActivity ca on ca.CustomerID = oi.CustomerID
Join commons.promoCode pc on pc.PromoID = oi.PromoID
WHERE
oi.PromoID != 'nil'
and pc.PromoID = :promoid
Group by
oi.PromoID,
ca.CustomerRegion,
pc.PromoDescription
Order By
totalPromoUsed DESC
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment