×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Ok, got it working. Had to change from
UNION
to
UNION ALL

SELECT assumes ALL and not DISTINCT
UNION assumes DISTINCT and not ALL

So, now this:
with t1 as (
select 'D' as RecType, Dude, Moola as Money
from qtemp.thoma),
t2 as (
select 'S' as RecType, Dude, sum(Moola) as Money
from qtemp.thoma
group by Dude,1)
select * from t1
union ALL
select * from t2
order by Dude, RecType, Money

Returns:
....+....1....+....2....+....
RECTYPE DUDE MONEY
D Tom 100
D Tom 100
S Tom 200
D Will 50
D Will 200
S Will 250
******** End of data ******

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 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.