Folks
I have two queries
Select Account_Id , Branch_Cd from Accounts
SELECT SUM (dbo.HOLDING.Shares_Par_Value_Qty * dbo.ASSET.Current_Prc) AS MarketValue
FROM dbo.HOLDING INNER JOIN
dbo.ASSET ON dbo.HOLDING.Property_Num = dbo.ASSET.Property_Num
Group by dbo.HOLDING.Account_ID
Account_ID is the same in both the queries ie in both the tables
Holding and Account.
I need the output like this
Select Account_Id, Branch_Cd, MarketValue from ---
But MarketValue should be calculated exactly in the above method.
How do I combine these two queries. I need it asap.
Help me out.
ThanksCheck my reply to your SUM post. If it isn't clear from that then get back to me.
Ursus|||How about:
SELECT A.Account_Id , A.Branch_Cd, B.MarketValue
FROM Accounts AS A
INNER JOIN
( SELECT SUM (dbo.HOLDING.Shares_Par_Value_Qty * dbo.ASSET.Current_Prc) AS MarketValue
FROM dbo.HOLDING
INNER JOIN dbo.ASSET
ON dbo.HOLDING.Property_Num = dbo.ASSET.Property_Num
GROUP BY dbo.HOLDING.Account_ID ) AS B
ON A.Account_ID = B.Account_ID
Monday, March 19, 2012
Nested Query (Urgent)
Labels:
account_id,
accountsselect,
asset,
branch_cd,
current_prc,
database,
dbo,
folksi,
holding,
microsoft,
mysql,
nested,
oracle,
queriesselect,
query,
server,
shares_par_value_qty,
sql,
sum,
urgent
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment