sql - Display column values only once -
supposed have following table. how display 'amount' once based on column id
?
id amount 1 10.00 1 10.00 1 10.00 2 10.00 2 10.00 2 10.00
given ff example expected output should :
id amount 1 10.00 1 0.00 1 0.00 2 10.00 2 0.00 2 0.00
i tried using row_number
not sufficient, giving me result.
id amount 1 10.00 1 0.00 1 0.00 2 0.00 2 0.00 2 0.00
edit : tried far :
select id ,case when row_number() over(partition amount order id) = 1 amount else 0.00 end [amount] table
just change partition use id:
select id ,case when row_number() over(partition id order id) = 1 amount else 0.00 end [amount] table order id, amount desc
Comments
Post a Comment