Skip to content
Advertisement

How to set succeeding row values as empty if same with previous row

How can I convert this table:

to something like this:

What I want to do is if the PropertyName is the same as the previous row succeeding row should be omitted. This should be the same for the Total.

I can’t try LAG/LEAD because we are only using SQL SERVER 2008 – i know it’s a bummer.

Advertisement

Answer

You can generate row numbers in a CTE expression, then select top most row numbers per PropertyName:

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