|
Hi,
Try the following:
With x as (Select MyCustomer as xCustomer, Min(MyDate) as xDate
From MyTable
Where ....
Group by MyCustomer)
Select a.*
from x join MyTable on xCustomer = MyCustomer and xDate = MyDate
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Dan
Gesendet: Thursday, January 11, 2007 20:47
An: Midrange Systems Technical Discussion
Betreff: SQL - multiple rows for same customer, but only want earliest one
I think I need an SQL boot camp.
I know this can be done, but the reference and/or programming guide need a
"If you want to do *this*, go here" type of chapter.
I have a select for which multiple rows can be returned for the same
customer number, but I only want the row that has the earliest transaction
date. It appears that DISTINCT will not return an entire row, and neither
does MIN. What am I missing?
TIA,
Dan
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.