Home » SQL & PL/SQL » SQL & PL/SQL » regarding date
regarding date [message #297535] Fri, 01 February 2008 04:43 Go to next message
msafana
Messages: 31
Registered: July 2007
Member
hi all,
please help me out of this,its urgent.
I have data like,
id date c3 c4 c5
1001 1/1/2005 a x 1
1001 1/1/2004 b y 2
1002 2/2/2004 c z 3
1002 2/2/2003 d n 4

I want to display the latest date with its data in the remaining columns and want to display only the maximum related date 'id' only,

Thanks for everyone.
Re: regarding date [message #297537 is a reply to message #297535] Fri, 01 February 2008 04:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
1/ Post your questions in Newbies forum
2/ urgent is meaningless in forum, read OraFAQ Forum Guide
3/ especially "How to format your post?" section. Use the "Preview Message" button to verify.
4/ Always post your Oracle version (4 decimals).
5/ Have a look at row_number, rank, dense_rank functions in SQL Reference

Regards
Michel
Re: regarding date [message #297546 is a reply to message #297535] Fri, 01 February 2008 05:32 Go to previous messageGo to next message
mshrkshl
Messages: 247
Registered: September 2006
Location: New Delhi
Senior Member
you need a simple query if i understand your problem.

select * from table_name where date_column in (select max(date_column) from table_name)
/


regards,
Re: regarding date [message #297549 is a reply to message #297546] Fri, 01 February 2008 05:54 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Are you sure is this what O/P wants ? Did you the read the post from Michael ? Did you test the sql ?

Regards

Raj
Re: regarding date [message #297550 is a reply to message #297546] Fri, 01 February 2008 05:54 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I don't know if "simple" is the appropriate word.

Regards
Michel
Re: regarding date [message #297645 is a reply to message #297535] Fri, 01 February 2008 22:31 Go to previous messageGo to next message
mshrkshl
Messages: 247
Registered: September 2006
Location: New Delhi
Senior Member
Quote:
Did you test the sql ?



 select empno,ename,hiredate,sal from emp
 where hiredate in (select max(hiredate) from  emp)
 /


     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20


regards,
Re: regarding date [message #297700 is a reply to message #297645] Sat, 02 February 2008 11:14 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Quote:
I want to display the latest date with its data in the remaining columns and want to display only the maximum related date 'id' only,

In which context your query meets the above criteria.

Regards

Raj
Re: regarding date [message #297817 is a reply to message #297535] Sun, 03 February 2008 22:22 Go to previous message
mshrkshl
Messages: 247
Registered: September 2006
Location: New Delhi
Senior Member
I think,we must wait for msafana response.

regards,
Previous Topic: Displaying output (merged)
Next Topic: A DB Trigger calling a Oracle Procedure Which in Turn Calls a Java Function
Goto Forum:
  


Current Time: Sat Dec 10 03:11:00 CST 2016

Total time taken to generate the page: 0.10260 seconds