Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION fnGetCustomerCount(@ProductKey AS INT)
- RETURNS INT AS
- BEGIN
- RETURN (SELECT P.EnglishProductName, count(C.FirstName) AS NoOfCustomers
- FROM Dimproduct AS P
- INNER JOIN FactInternetSales AS F ON P.ProductKey = F.ProductKey
- INNER JOIN DimCustomer AS C ON C.CustomerKey = F.CustomerKey
- WHERE P.ProductKey = @ProductKey
- GROUP BY P.EnglishProductName)
- END
- Select count(CustomerID), ProductID from Sales
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement