Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Syntax for calculated column from subquery results
Message
 
 
À
06/08/2008 21:35:48
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01337104
Message ID:
01337130
Vues:
10
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform