Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Syntax for calculated column from subquery results
Message
 
 
To
06/08/2008 21:35:48
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
01337104
Message ID:
01337130
Views:
11
Yes, it'll work too but it performs one extra select.

>Your approach got me thinking and I came up with a modification of my original proc that seems to give me what I want
>
>
>SELECT main.*, main.credits- main.debits - main.creditedamt as balance FROM
>(	SELECT
>		credits = (SELECT SUM(ac.yamount)
>			FROM account_credits ac
>			WHERE ac.cinmates_id = @cinmates_id) ,
>		debits = (SELECT sum(ad.yamount)
>			from account_debits ad
>			WHERE ad.cinmates_id=@cinmates_id) ,
>		creditedamt = (SELECT sum(ad.ycreditedamt)
>			from account_debits ad
>			WHERE ad.cinmates_id=@cinmates_id )
>) main
>
>
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform