The SQL below works perfectly. It is a combination of a JOIN, UNION, and subselect.
Along with other columns, there is one amount column in the result.
select * from miscchg A
where exists
(select * from miscchgplg b
where
a.ASHPNBR = b.ashpnbr
and a.ABLDNGD = b.ABLDNGD )
union all
select * from miscchgplg
How can I aggregate the result set by GROUPing by a key field and SUMming the amounts in each record?
Would I be better off CREATING a new temp table and then doing the grouping as a 2 step process?
(for simplicity and self-doc)
Thanks
______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs Skyscan service.
For more information please visit
http://www.symanteccloud.com
______________________________________________________________________
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.