home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / database / 6343 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1.5 KB

  1. Xref: sparky comp.databases:6343 comp.databases.theory:399 comp.databases.oracle:1382
  2. 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!
  3. From:  (Bill Winett)
  4. Newsgroups: comp.databases,comp.databases.theory,comp.databases.oracle
  5. Subject: Re: Is this a bug or a limitation of the SQL language
  6. Message-ID: <29765@goofy.Apple.COM>
  7. Date: 25 Aug 92 19:00:41 GMT
  8. References: <1992Aug23.074048.16681@prism.poly.edu>
  9. Sender: usenet@Apple.COM
  10. Organization: Apple
  11. Lines: 30
  12.  
  13. In article <1992Aug23.074048.16681@prism.poly.edu>, sjha@prism.poly.edu (Salil Kumar Jha) writes:
  14. > I tried to do this query in Oracle and DB2 and both failed. I know its
  15. > not allowed but why not?
  16. > Assume the use of the classic oracle emp table
  17. > select * from emp 
  18. > where salary between
  19. > (select salary from emp where ename = 'Larry')
  20. > and
  21. > (select salary from emp where ename = 'John')
  22. > Isnt this the best way of finding all people whose salaries lie between those
  23. > of Larry and John (without knowing whose is larger)
  24. > sjha@prism.poly.edu
  25. Boy, my first response was really stupid.  Too bad I didn't realize it before
  26. I sent it.  Let me try again:
  27.  
  28. select * from emp
  29. where salary >= (select min(salary)
  30.                  from emp
  31.                  where ename in ('Larry','John')
  32. and   salary <= (select max(salary)
  33.                  from emp
  34.                  where ename in ('Larry','John')
  35.  
  36. Now, does that do it?
  37.