I want to get the count of ‘unitsold’ for each Name from 3/1/2022 and 4/1/2022. For example Name ‘a’ required to count its units sold from 3rd to 8th day.
SQL query:
select Name, sum(unitsold) over (partion by Name order by Asc) from table1
The above query will provide units sold for the entire date range. But how to get sum of units sold from 3rd day to 8th day of each name?
2
Answers
This is the query which gives the out put.
The case handles day logic and where clause handles the date range of 1 month.
Hope this helps, Thanks.