Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
goligol
Posting Yak Master
128 Posts |
Posted - 2013-02-15 : 15:16:48
|
Hi I would like to combine the all_qty_1_yr when the FIPS is the same:like for the first two rows, I would like to sum the 19800 + 17994 because the FIPS is the same for this two values 01097in new view I would like to keep:FIPS all_qty_1yr columns only by having the summation on same FIPSnaics FIPS ust_code all_qty_1_yr all_qty_2_yr11133912 01097 4840 19800 011133905 01097 4840 17994 011133913 04003 2010 375712.036007496 011133902 04003 2010 2017876.49509041 011133914 04013 2010 103561.978092157 011133505 04013 1220 9048 011133505 04023 2010 7502362 011132006 04023 2010 24114931.0388845 011133202 04023 2010 2636366 98073367611133408 04023 2010 4595.98865871247 0Thank you |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-15 : 15:54:41
|
Didn't quite follow what you meant by "columns only by having the summation on same FIPS". Also, did you want the other columns to show up in the output - if so how should they be aggreated? If this query does not give you what you want, can you post the desired output?SELECT FIPS, SUM(all_qty_yr) AS Total_all_qty_yrFROM TblGROUP BY FIPS; |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-16 : 02:28:41
|
Based on your explanation it would either of James suggestion or thisSELECT *,SUM(all_qty_1_yr) OVER (PARTITION BY FIPS) AS CummSumFROM table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
goligol
Posting Yak Master
128 Posts |
Posted - 2013-02-18 : 13:10:54
|
Thank you James and VisaKh. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-18 : 13:31:53
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|