Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Syntax for calculated column from subquery results
Message
 
 
À
06/08/2008 19:34:32
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01337104
Message ID:
01337122
Vues:
10
This message has been marked as the solution to the initial question of the thread.
You can try
select *, myCalcField from (your select statement) myInnerSelect
>
	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 )
>
>
>In the above stored proc I would like to add a 4th colum which is balance=credits-debits-creditedamt
>
>Would also appreciate any insights as to other ways to design this select.
>
>TIA
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform