Skip to content
Advertisement

SQL Insert into duplicates

My code is as follows:

I should explain the SUM(), there are differing dates on schedule such as

I want to get all the “count” of “serviceId” beyond today hence the ‘date >= GETDATE()’

Basically I want the table to look like so:

I am able to get the values but I get them like so:

Whereas I want to display as

Any and all help is appreciated. Where I’m wrong, syntax/performance improvement, references, anything.

Advertisement

Answer

You can do it with conditional aggregation:

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