SQL Server SUM/Group/Window Function -
good day, have table follows.
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.
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
Post a Comment