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 |
rjhe22
Constraint Violating Yak Guru
283 Posts |
Posted - 2014-01-21 : 11:38:23
|
hi have this codeUpdate dbo.SSCIREWorkingDataloadFileset LocalCrossTrade = BASE_MKT_VALwhere INV_SECTYPE_COD = '61'or INV_SECTYPE_COD = '62'or INV_SECTYPE_COD = '63'or INV_SECTYPE_COD = '64'or INV_SECTYPE_COD = '65'or INV_SECTYPE_COD = '71'or INV_SECTYPE_COD = '72'or INV_SECTYPE_COD = '73'or INV_SECTYPE_COD = '74'or INV_SECTYPE_COD = '75' where it say LocalCrossTrade = BASE_MKT_VAL i want to sum the BASE_MKT_VAL fields and set that equal to the LocalCrossTradewhats the best way to do this |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-01-21 : 19:19:41
|
Can I ask you to elaborate a little? You want to sum BASE_MKT_VAL over the entire table? Only where INV_SECTYPE_CODE = '61', '62', etc.? Grouped by some other column? Perhaps some sample data and expected outputs would shed some light.=================================================A man is not old until regrets take the place of dreams. - John Barrymore |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-22 : 06:57:41
|
[code]Update tset LocalCrossTrade = Total_BASE_MKT_VALFROM(SELECT *,SUM(BASE_MKT_VAL) OVER (PARTITION BY <somefieldhere>) AS Total_BASE_MKT_VALFROM dbo.SSCIREWorkingDataloadFilewhere INV_SECTYPE_COD IN ('61','62','63','64','65','71','72','73','74','75'))t[/code]Please fill part in blue by field(s) based on which you want to sum the BASE_MKT_VAL field------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|