Home » SQL & PL/SQL » SQL & PL/SQL » Getting only the first returned row from a select query
Getting only the first returned row from a select query [message #189254] Wed, 23 August 2006 17:15 Go to next message
Rustican
Messages: 51
Registered: July 2006
Member
I have a table that has 10 rows with a date field. I want my query to order by date and only return the first row. I don't want to use max because i want the entire row returned. I tried using rownum = 1 but doesn't work either. Is there anything else i can try?

Re: Getting only the first returned row from a select query [message #189256 is a reply to message #189254] Wed, 23 August 2006 17:20 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select *
  from (select *
          from t
         order by dt desc)
 where rownum = 1;
Re: Getting only the first returned row from a select query [message #189282 is a reply to message #189256] Thu, 24 August 2006 00:30 Go to previous messageGo to next message
m_Usuf
Messages: 21
Registered: November 2005
Location: Karachi Pakistan
Junior Member

Hey,,,,,,,,


Equal sign will not work......... So Follow the query.


SELECT * FROM tablename WHERE rownum<2;

You will got your result.

Thanxxxxxxx

Yousuf
Re: Getting only the first returned row from a select query [message #189284 is a reply to message #189282] Thu, 24 August 2006 00:34 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
m_Usuf wrote on Thu, 24 August 2006 07:30

Equal sign will not work..

Could you please explain? I bet you have an example showing us that Todd's query doesn't work?
Previous Topic: Problem with XMLROOT (Merged)
Next Topic: inbuilt oracle function
Goto Forum:
  


Current Time: Sun Dec 04 14:29:26 CST 2016

Total time taken to generate the page: 0.19547 seconds