Skip to content
Advertisement

Aggregate quantity columns per distinct date in table sql

I want to sum quantity column from first date in table (2016-02-17 in this table) until per each distinct date in the table. Result relation should contains sum of quantities per each distinct date in table. how can I write a query for this in sql server?

Expected output:

Advertisement

Answer

Aggregate function SUM with GROUP BY will give you the sum values for the Distinct dates.

Check the SQL Fiddle for reference.

If you want the result for ID specific, use this. The PARTITION will make the difference.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement