Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. CREATE FUNCTION fnGetCustomerCount(@ProductKey AS INT)
  2. RETURNS INT AS
  3. BEGIN
  4. RETURN (SELECT P.EnglishProductName, count(C.FirstName) AS NoOfCustomers
  5. FROM Dimproduct AS P
  6. INNER JOIN FactInternetSales AS F ON P.ProductKey = F.ProductKey
  7. INNER JOIN DimCustomer AS C ON C.CustomerKey = F.CustomerKey
  8. WHERE P.ProductKey = @ProductKey
  9. GROUP BY P.EnglishProductName)
  10. END
  11.  
  12. Select count(CustomerID), ProductID from Sales
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement