| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> SQL problem
Hello, I have two SQL statements which *should* return the same count. I can't
figure out why they don't. Can anyone tell me why?
Number 1:
SELECT count(saradap_pidm)
FROM saturn.saradap
WHERE saradap_term_code_entry = '199840'
and saradap_admt_code in ('IN', 'NA', 'ED', 'DA')
and exists(select 'x' from saturn.sarappd
where sarappd_apdc_code in ('Z', 'AZ', 'DZ')
and saradap_appl_no = sarappd_appl_no
and sarappd_pidm = saradap_pidm)
and not exists(select 'x' from saturn.sarappd
where sarappd_apdc_code in ('SF', 'SH')
and saradap_appl_no = sarappd_appl_no
and sarappd_pidm = saradap_pidm)
Number 2:
SELECT count(saradap_pidm)
FROM saturn.saradap, saturn.sarappd
WHERE sarappd_pidm = saradap_pidm
and saradap_appl_no = sarappd_appl_no
and saradap_term_code_entry = '199840'
and saradap_admt_code in ('IN', 'NA', 'ED', 'DA')
and sarappd_apdc_code in ('Z', 'AZ', 'DZ')
and sarappd_apdc_code not in ('SF', 'SH')
--
Phil R Lawrence phone: 610-758-3051 Programmer / Analyst e-mail: prl2_at_lehigh.edu194 Lehigh University Computing Center
![]() |
![]() |