Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created January 27, 2016 08:02
Show Gist options
  • Save dnasca/2c15be244c3810ac06af to your computer and use it in GitHub Desktop.
Save dnasca/2c15be244c3810ac06af to your computer and use it in GitHub Desktop.
Applying predicates to a group
-- applying predicates to a group
SELECT
SOD.ProductID,
SOD.SpecialOfferID,
SUM(SOD.OrderQty) AS OrderQtyByProductId
FROM
Sales.SalesOrderDetail AS SOD
GROUP BY
SOD.ProductID,
SOD.SpecialOfferID
HAVING SUM(SOD.OrderQty) >= 100
ORDER BY
SOD.ProductID,
SOD.SpecialOfferID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment