home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.databases:6343 comp.databases.theory:399 comp.databases.oracle:1382
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!apple!
- From: (Bill Winett)
- Newsgroups: comp.databases,comp.databases.theory,comp.databases.oracle
- Subject: Re: Is this a bug or a limitation of the SQL language
- Message-ID: <29765@goofy.Apple.COM>
- Date: 25 Aug 92 19:00:41 GMT
- References: <1992Aug23.074048.16681@prism.poly.edu>
- Sender: usenet@Apple.COM
- Organization: Apple
- Lines: 30
-
- In article <1992Aug23.074048.16681@prism.poly.edu>, sjha@prism.poly.edu (Salil Kumar Jha) writes:
- >
- > I tried to do this query in Oracle and DB2 and both failed. I know its
- > not allowed but why not?
- >
- > Assume the use of the classic oracle emp table
- >
- > select * from emp
- > where salary between
- > (select salary from emp where ename = 'Larry')
- > and
- > (select salary from emp where ename = 'John')
- >
- > Isnt this the best way of finding all people whose salaries lie between those
- > of Larry and John (without knowing whose is larger)
- >
- > sjha@prism.poly.edu
- >
- Boy, my first response was really stupid. Too bad I didn't realize it before
- I sent it. Let me try again:
-
- select * from emp
- where salary >= (select min(salary)
- from emp
- where ename in ('Larry','John')
- and salary <= (select max(salary)
- from emp
- where ename in ('Larry','John')
-
- Now, does that do it?
-