Skip to content
Advertisement

Grouping By Date When Used In Case

I’ve got a working query where I can export to Excel and pivot myself to not be grouped by the fldTrancationDateTime column and that is working fine as a short term solution.

Is the only option here to use SQL pivot so I can only group by the Product and have each date range populated? Instead of one row for each date? Or am I going about coding this incorrectly?

Output Here

Advertisement

Answer

I am guessing you want conditional aggregation:

The case expression is the argument to the sum() rather than the other way around.

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