-
Hi Gurus,
Have a table with following data
Name date
James 5-MAR-02
Janes 6-MAR-02
John 6-MAR-02
John 8-MAR-02
I need a select where I get the latest date for a particular user.
Thanks!
Hemant
-
select name, max(date) from table_name
group by name;
SQL> select * from supp2;
NAME DATE_IN
---------- ---------
John 16-SEP-02
John 13-SEP-02
James 15-SEP-02
James 14-SEP-02
James 13-SEP-02
SQL> select name, max(date_in)
2 from supp2
3 group by name;
NAME MAX(DATE_
---------- ---------
James 15-SEP-02
John 16-SEP-02
-
If u need to get data about all users --> see stecal post.
If u need only one particular user:
select max(date_in) from t1 where name = 'John';
or
select name, max(date_in) from t1
group by name
having name = 'John';
-
Originally posted by Shestakov
If u need to get data about all users --> see stecal post.
If u need only one particular user:
select max(date_in) from t1 where name = 'John';
or
select name, max(date_in) from t1
group by name
having name = 'John';
Note that the first statement is far more efficient than the second.
- Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|