Skip to main content
added 5 characters in body
Source Link
Malachi
  • 28.7k
  • 11
  • 86
  • 188

Essentially I'm atteptingattempting to select the top read (based on read_dateread_date), and check if it has a type in ( 'R','S','C','B','Q','F','I','A')type in ( 'R','S','C','B','Q','F','I','A')

select *
from (
        select *
        from (
           select *
           FROM table
           WHERE  id = 369514
           order by read_date desc
            )
         where rownum = 1
         )
 where type IN ( 'R','S','C','B','Q','F','I','A')

I only need to return a row if the top row has a type in the set, if not return nothing.

The only way I seem to be able to is using all these nasty sub-queries.

Essentially I'm attepting to select the top read (based on read_date), and check if it has a type in ( 'R','S','C','B','Q','F','I','A')

select *
from (
        select *
        from (
           select *
           FROM table
           WHERE  id = 369514
           order by read_date desc
            )
         where rownum = 1
         )
 where type IN ( 'R','S','C','B','Q','F','I','A')

I only need to return a row if the top row has a type in the set, if not return nothing.

The only way I seem to be able to is using all these nasty sub-queries.

Essentially I'm attempting to select the top read (based on read_date), and check if it has a type in ( 'R','S','C','B','Q','F','I','A')

select *
from (
        select *
        from (
           select *
           FROM table
           WHERE  id = 369514
           order by read_date desc
            )
         where rownum = 1
         )
 where type IN ( 'R','S','C','B','Q','F','I','A')

I only need to return a row if the top row has a type in the set, if not return nothing.

The only way I seem to be able to is using all these nasty sub-queries.

Source Link
m.edmondson
  • 327
  • 1
  • 2
  • 9

Oracle nested query

Essentially I'm attepting to select the top read (based on read_date), and check if it has a type in ( 'R','S','C','B','Q','F','I','A')

select *
from (
        select *
        from (
           select *
           FROM table
           WHERE  id = 369514
           order by read_date desc
            )
         where rownum = 1
         )
 where type IN ( 'R','S','C','B','Q','F','I','A')

I only need to return a row if the top row has a type in the set, if not return nothing.

The only way I seem to be able to is using all these nasty sub-queries.