SQL Server SUM/Group/Window Function -


good day, have table follows.

before adding new column

what love add new column tabulate/summarize (anyway possible) called "new net" covid/policyno/covyear/positive(negative) values.

in example below new column this. in short, trying sumup values in group , place total in first row of group , 0 out others. help/pointers appreciated this. have tried sql server window functions, standard sum/group.

enter image description here

this should meet ypur expectations:

select  policyno ,         covid ,          covyear ,         p ,         net,          case when row_number()over(partition covid, policyno, covyear, net order policyno) = 1 net else 0 end newnet    dbo.test1; 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -