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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -