home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!paladin.american.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!news.columbia.edu!lamont!msolda
- From: msolda@lamont.ldgo.columbia.edu (M Solda)
- Subject: Re: multiple EXISTS subqueries under Sybase 4.8
- Message-ID: <1992Nov19.174435.25700@lamont.ldgo.columbia.edu>
- Keywords: EXISTS, 4.8, sun4, sunos 4.1.1
- Sender: news@lamont.ldgo.columbia.edu
- Reply-To: msolda@lamont.ldgo.columbia.edu
- Organization: Lamont-Doherty Geological Observatory
- References: <1992Nov14.174847.29576@lamont.ldgo.columbia.edu> <1992Nov15.144258.18635@panix.com> <1992Nov15.225853.2269@lamont.ldgo.columbia.edu> <1e8fj7INN1sg@gazette.bcm.tmc.edu> <1992Nov16.184540.11698@lamont.ldgo.columbia.edu> <1ee852INN90m@gazette.bcm.tmc.edu>
- Date: Thu, 19 Nov 1992 17:44:35 GMT
- Lines: 52
-
- In article <1ee852INN90m@gazette.bcm.tmc.edu>, mparsons@fleming.csc.bcm.tmc.edu (Mark Parsons) writes:
- >
- > In article <1992Nov16.184540.11698@lamont.ldgo.columbia.edu>, msolda@lamont.ldgo.columbia.edu (M Solda) writes:
- > |> > Ummmmmmm, if you're still working on it, could you post the example
- > |> > code? I'm not quite following this.
- > |> >
- > |>
- > |> okay, here it is:
- > |>
- >
- > <UNIONed EXISTS and NOT EXISTS code deleted>
- >
- > *blush* I should've said "post the original problem code", i.e.,
- > not the union version . . .
-
- here is the query that would not work:
-
-
- select last_name, first_name, salary, title
- from employee_id i1, salary_history s1, employee_status e1
- where (
- (exists (select *
- from salary_history
- where ss_num = s1.ss_num
- and comment = 'Employment'
- and salary_scope_begin <= '9/1/2'
- and salary_scope_begin > (select max(status_begin)
- from employee_status
- where status_begin < '9/1/2'
- and ss_num = s1.ss_num)))
- or
- (not exists (select *
- from employee_status
- where status_begin < '9/1/2'
- and ss_num = s1.ss_num))
- )
- and salary_scope_begin = (select max(salary_scope_begin)
- from salary_history
- where ss_num = s1.ss_num
- and salary_scope_begin <= '9/1/2')
- and employee_id.ss_num = salary_history.ss_num
- and employee_id.ss_num = employee_status.ss_num
- and status_begin is NULL
- and title_effective_date = (select max(title_effective_date)
- from employee_status
- where title_effective_date <= '9/1/2'
- and ss_num = s1.ss_num)
- order by title, last_name
- compute avg(salary), count(title) by title
- compute avg(salary), count(title)
-
- msolda
-