Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with sum query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Help with sum query
Divers
Thread ID:
00760459
Message ID:
00760459
Vues:
44
I am using a sum and group by in my query to find differences in a total field in a parent table and the child tables.
select o.ytotalorder-sum(ar.yamttrans) as diff
from orders o inner join orderardetail ar on o.uordid=ar.uordid
where (ar.cartypid='II' or ar.cartypid='IM') and o.tcreate>='2002-12-18' group by o.uordid,o.ytotalorder
having o.ytotalorder>sum(ar.yamttrans)
order by o.uordid
This works fine. It gives me a list of the orders that are out of balance. Now I want to get a grand total of those differences (sum the difference). Is there a way to do it in T-Sql?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform