Home » SQL & PL/SQL » SQL & PL/SQL » Need Newest Record From Each ID Group
Need Newest Record From Each ID Group [message #37654] Tue, 19 February 2002 06:01 Go to next message
Greg
Messages: 35
Registered: July 2000
Member
I need to find the newest record in a table for all station ids. I have a
field start_date to search on. Below is an example of the records I want.
Startion ID Date
1............01/01/01
2............01/01/01
2............01/15/01
1............01/15/01 want this record
2............01/23/01
2............02/01/01 want this record
Re: Need Newest Record From Each ID Group [message #37656 is a reply to message #37654] Tue, 19 February 2002 06:31 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
try one of these

select *
from your_table t1
where your_date =(select max(your_date) from your_table t2 where t1.station_id=t2.station_id)

select *
from your_table
where your_date in (select max(your_date) from your_table group by station_id);
Previous Topic: CREATE TABLE/CONSTRAINT PROBLEM
Next Topic: how to?
Goto Forum:
  


Current Time: Tue Apr 16 08:08:48 CDT 2024