Last active
May 15, 2022 07:47
-
-
Save nordineb/91e7da4320c27cb71a31b849c5197ba0 to your computer and use it in GitHub Desktop.
top 5 buyers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @customerordersinput string = "/Data/Meny/Output/customerorders.csv"; | |
DECLARE @cvsout string = "/Data/Meny/Output/top5buyers.csv"; | |
@customersorders = | |
EXTRACT CustomerId int, | |
CustomerFirstName string, | |
CustomerLastName string, | |
ProductName string, | |
ProductPrice int, | |
Quantity int | |
FROM @customerordersinput | |
USING Extractors.Csv(encoding: Encoding.UTF8); | |
@ds = | |
SELECT c.CustomerId AS customerid, ANY_VALUE(c.CustomerFirstName) AS firstname, ANY_VALUE(c.CustomerLastName) AS lastname, SUM(c.ProductPrice) AS total, COUNT(Quantity) AS NumberOfOrders | |
FROM @customersorders AS c | |
GROUP BY c.CustomerId | |
ORDER BY total DESC | |
FETCH 10 ROWS; ; | |
OUTPUT @ds | |
TO @cvsout | |
USING Outputters.Csv(encoding:Encoding.UTF8, quoting: false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment