Home » SQL & PL/SQL » SQL & PL/SQL » Table Output
Table Output [message #277031] Sun, 28 October 2007 02:24 Go to next message
thisisnatesh
Messages: 92
Registered: March 2007
Member
Hi All

I am getting a set of records from inline query like

latest_flag || Type || Date_dt
1 ............... Tin ..... 05/05/07
1 ............... RH ..... 01/05/07
2 ............... RH ..... 10/05/07

Now, i want to retrieve the records like

latest_flag || Type || Date_dt
1 ............... Tin ..... 05/05/07
2 ............... RH ..... 10/05/07

ie, second record is retrieved on the basis of highest latest flag value of type RH.
first record is retrieved on the basis of highest latest flag value of type Tin. as it is 1 it retrieved the same record.

Please help me on this regard

Thanks in Advance
Natesh

[Updated on: Sun, 28 October 2007 02:28]

Report message to a moderator

Re: Table Output [message #277033 is a reply to message #277031] Sun, 28 October 2007 02:26 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Just search for "top N" queries, this has been asked many and many times.

Regards
Michel
Re: Table Output [message #277034 is a reply to message #277033] Sun, 28 October 2007 02:36 Go to previous messageGo to next message
thisisnatesh
Messages: 92
Registered: March 2007
Member
Hi
I have tried in many ways using top n query with my knowledge. but, i couldnt get the required output.
can you post the query?
Thanks in advance
NTesh
Re: Table Output [message #277043 is a reply to message #277034] Sun, 28 October 2007 03:28 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why wouldn't you post YOUR queries so that we could see what you did wrong and help you fix it?
Re: Table Output [message #277071 is a reply to message #277031] Sun, 28 October 2007 07:17 Go to previous messageGo to next message
Omar Hattab
Messages: 2
Registered: October 2007
Location: Jordan
Junior Member

Hi ,

select latest_flag || type ||Date_dt
from T_NAME A
where latest_flag in (select max(latest_flag)
from T_NAME B
where B.type = A.type)
order by type , latest_flag desc ;





i am not sure if this the best way to get what you need ,
Please If any one have a more professional way , help us

Thank you

[Updated on: Sun, 28 October 2007 07:18]

Report message to a moderator

Re: Table Output [message #277074 is a reply to message #277071] Sun, 28 October 2007 08:33 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Michel Cadot wrote on Sun, 28 October 2007 08:26

Just search for "top N" queries, this has been asked many and many times.


In addition, read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Please always post your Oracle version (4 decimals).

Regards
Michel

[Updated on: Sun, 28 October 2007 08:34]

Report message to a moderator

Previous Topic: PLS_INTEGER
Next Topic: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Goto Forum:
  


Current Time: Sat Dec 10 11:11:18 CST 2016

Total time taken to generate the page: 5.92745 seconds