Hi I have the following 2 queries
[code]
UPDATE m
SET m.Marketprice= f.tempmarketvalue1
FROM [dbo].[BNYUKGSL113Table] m
INNER JOIN
(
SELECT [Counterpartyborrower],[Trade_type], [Account],SUM([MarketValueBaseCurrency]) as tempmarketvalue1
FROM [dbo].[BNYUKGSL113Table]
WHERE ( [Trade_type]='Loan')
GROUP BY [Counterpartyborrower],[Trade_type], [Account]
) f ON m.[Counterpartyborrower] = f.[Counterpartyborrower] AND m.[Trade_type] = f.[Trade_type] AND m.[Account] = f.[Account]
UPDATE m
SET m.Marketprice= f.tempmarketvalue2
FROM [dbo].[BNYUKGSL113Table] m
INNER JOIN
(
SELECT [Counterpartyborrower],[Trade_type],SUM([MarketValueBaseCurrency]) as tempmarketvalue2
FROM [dbo].[BNYUKGSL113Table]
WHERE ( [Trade_type]='Loan')
GROUP BY [Counterpartyborrower],[Trade_type]
) f ON m.[Counterpartyborrower] = f.[Counterpartyborrower] AND m.[Trade_type] = f.[Trade_type]
[\code]
what i want to do is join both queries and get the sql to divide the f.tempmarketvalue1 by f.tempmarketvalue2 where the [Counterpartyborrower] are the same to populate a field in the table with the value.
is this possible and how can i do it?