Skip to content
Advertisement

How do I include an additional non-aggregated column for each of my in my PIVOT values?

I have the following code fragment which gives me the current results below. I’m attempting to add an additional column for each of my pivoted values in order to include the lastview data for each of my siteuserid / tagname combo (see expected results). Since this column isn’t an aggregation, I don’t believe an additional pivot would help. I’ve tried multiple ways of adding lastview, but it always results in additional rows rather than the desired output.

Current Result

Desired Result

Advertisement

Answer

try the following:

Please see db<>fiddle here.

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