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 -

excel - I can't get the attachement of the email PHP -

node.js - Express and Redis - If session exists for this user, don't allow access -