Select * from ( Select etc..)

Started by Jeff Postabout 25 years ago2 messagesgeneral
Jump to latest
#1Jeff Post
postjeff@uwm.edu

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jeff Post (#1)
Re: Select * from ( Select etc..)

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