Thread: Select * from ( Select etc..)

Select * from ( Select etc..)

From
Jeffery L Post
Date:
Hello,
I am just wondering how I can select from a generated dataset.
ex.
  Select * from (
    select first, last from staff where salary > 12000
   union
    select first, last from staff where salary < 50000
   )
  order by last

I just took a class in oracle and I thought I remember doing just such a
thing. I know that Oracle does a lot of non-standard sql stuff but it
seems that this would be part of the standard.... I read through the to-do
list to see if it is somthing that is being worked on. But that just
stumped me....   What is this sort of thing called? selecting from a
generated dataset and is it somthing that is being worked on. Or is it
just somthing that I am making up in my head..


Thanks
    Jeff Post
University of Wisconsin - Milwaukee


Re: Select * from ( Select etc..)

From
Tom Lane
Date:
Jeffery L Post <postjeff@uwm.edu> writes:
> I am just wondering how I can select from a generated dataset.

Use 7.1.

> ex.
>   Select * from (
>     select first, last from staff where salary > 12000
>    union
>     select first, last from staff where salary < 50000
>    )
>   order by last

... although this example is not exactly compelling, since you could
just write

    select first, last from staff where salary > 12000
   union
    select first, last from staff where salary < 50000
   order by last

            regards, tom lane