Group,
I have a money field that I need to sum separately, giving me two
different results, is this possible in a select statement?


ID
Date
Money
123
10/1/2016
$0.00
123
11/1/2016
$5.00
123
11/1/2016
$2.00
123
12/1/2017
$10.00
123
8/9/2018
$3.00

456
4/1/2016
$0.00
456
4/25/2016
$0.00
456
5/1/2016
$2.00
456
8/1/2017
$5.00
456
12/1/2017
$12.00

From the example above, I need this result:
ID - 123
total money = $20.00
first money = $7.00

ID - 456
Total money = $19.00
first money = $2.00

#1
this gets my “total money”
select id, sum(money) as “total money” from mylib.myfile
group by id

#2
this ALMOST gets my result for “first money”
select tmdonr, sum(tmamnt) from mylib.myfile
group by tmdonr, tmupdti
having sum(tmamnt) > 0
order by tmdonr, tmupdti asc
**the above returns rows for each date, I only want the first MONEY
entry (11/1/2016 with $5.00)

I'm trying to put these 2 selects together, but it's looking pretty ugly.
Can I accomplish this with one select statement?


Diane Mueller
Association of the Miraculous Medal




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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

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.