Skip to content

Instantly share code, notes, and snippets.

@karenpayneoregon
Last active July 11, 2020 12:10
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 karenpayneoregon/18df5808020872215895192c50fcd482 to your computer and use it in GitHub Desktop.
Save karenpayneoregon/18df5808020872215895192c50fcd482 to your computer and use it in GitHub Desktop.
Get products by category for NorthWind2020
DECLARE @CategoryID INT= 2;
SELECT P.ProductID,
P.ProductName,
P.UnitPrice,
P.UnitsInStock,
P.SupplierID,
S.CompanyName AS SupplierName,
C.[Name] AS SupplierCountry
FROM Products AS P
INNER JOIN Suppliers AS S ON P.SupplierID = S.SupplierID
INNER JOIN Countries AS C ON S.CountryIdentifier = C.CountryIdentifier
WHERE P.CategoryID = @CategoryID;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment