Hi
I have data as follows
[code]
ID | Fundcode | SecurityName | MarketValue |
---|---|---|---|
1305357 | 261600 | Deliver ARSReceive USD | -666.37 |
1305424 | 261600 | Deliver ARSReceive USD | -1027.93 |
1324842 | 261600 | Deliver ARSReceive USD | 8893.12 |
1327421 | 261600 | Deliver ARSReceive USD | 1808.53 |
1332566 | 261600 | Deliver ARSReceive USD | -5247.47 |
[\code]
What i am looking to to is sum market value based on securityname and fundcode but only populated the summed value to on of the 5 outputs above.
I was trying the following but the group by is killing it
[code[
UPDATE m
SET m.[MarketValueofSharesSold]=f.MarketValue
FROM [dbo].[BNYUKWorkingDataloadFile2] m
INNER JOIN
(
SELECT [FundCode],SUM([MarketValue]) MarketValue ,ROW_NUMBER() over (Partition by [FundCode],[SecurityName] order by [FundCode],[SecurityName]) AS rowNumber
FROM [dbo].[BNYUKWorkingDataloadFile2]
GROUP BY [FundCode],[SecurityName]
) f ON m.[FundCode] = f.[FundCode] AND m.[SecurityName] = f.[SecurityName]
Where rowNumber = 1
[\code]
Anyone any ideas