×

Good News Everybody!

The new search engine is LIVE!

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




Diane,

I think this should work:

WITH t1
AS (SELECT id, MIN(date1) AS first_date
FROM mylib.test GROUP BY id)
,t2
AS (SELECT id, SUM(money) AS tot_money
FROM mylib.test GROUP BY id)

SELECT t1.id
,(SELECT money FROM mylib.test
WHERE id = t1.id AND date1 = t1.first_date)
AS first_money
,t1.first_date
,t2.tot_money FROM t1 INNER JOIN t2 USING(id)


Be sure to have appropiate indexes by date and id.

HTH,
Luis Rodriguez


This thread ...

Follow-Ups:
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.