Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Selecting rows by earliest date
Mon, Aug 31 2009 12:19 PMPermanent Link

Mark Shapiro
Given the following table values:

status_id   person_id   entry_date   entry_status
1              3               8/17/2009    HA
2              3               8/19/2009    HA
3              3               7/23/2009    HP
4              2               8/22/2009    HA
5              4               8/23/2009    HP


how would I pull out the rows that represented the earliest date for each unique person_id
plus entry_status combination? In this example, I would want to return rows 1, 3, 4, and 5.

Mark Shapiro
Mon, Aug 31 2009 3:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< how would I pull out the rows that represented the earliest date for each
unique person_id plus entry_status combination? In this example, I would
want to return rows 1, 3, 4, and 5. >>

Use this query:

SELECT person_id, entry_status, MIN(entry_date) AS earliest_entry_date
FROM MyTable
GROUP BY person_id, entry_status

--
Tim Young
Elevate Software
www.elevatesoft.com

Image