I have a select query, which returns many same ordered values in one column.
Looks like this:
Id | Type |
---|---|
1 | A |
2 | A |
3 | A |
4 | B |
5 | B |
6 | C |
7 | C |
8 | C |
But I like to display like this:
Id | Type |
---|---|
1 | A |
2 | |
3 | |
4 | B |
5 | |
6 | C |
7 | |
8 |
Thanks for any advice!
CodePudding user response:
You can use lag
window function,
select t.id,
case when lag([type]) over(order by id)=[type] then '' else [type] end [Type]
from t