Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Subquery Question
David,
Thanks for your suggestion. It helps a little but not entirely. When I run your second suggestion (select ARBEITSPLAN_NR
from w100.papp where papp.BELEGUNGSEINHEIT_NR in (3400,3500,3430) and ARBEITSPLAN_NR in (select papp.ARBEITSPLAN_NR from w100.papp group by ARBEITSPLAN_NR having count (papp.ARBEITSPLAN_NR) = 3); )
I get ARBEITSPLAN_NR with only 3 BELEGUNGSEINHEIT_NR (this is good) but I get BELEGUNGSEINHEIT_NR that have also other BELEGUNGSEINHEIT_NR outside of the (3400,3500,3430) Example:
ARBEITSPLAN_NR = 123456
BELEGUNGSEINHEIT_NR = 3400 BELEGUNGSEINHEIT_NR = 1234 BELEGUNGSEINHEIT_NR = 5678
What I'm looking for is an ARBEITSPLAN_NR with 3 BELEGUNGSEINHEIT_NR like above but only with BELEGUNGSEINHEIT_NR = 3400,3500,3430 Example:
ARBEITSPLAN_NR = 123456
BELEGUNGSEINHEIT_NR = 3400 BELEGUNGSEINHEIT_NR = 3500 BELEGUNGSEINHEIT_NR = 3430
The above statement can return any combination of the 3 "BELEGUNGSEINHEIT_NR" I know that there are 148 records that contain what I'm looking for but I can't veiw what they are.
I run the following query to find all the records I don't want:
select papp.ARBEITSPLAN_NR,sum(papp.BELEGUNGSEINHEIT_NR)
from w100.papp,w100.papk
where papp.ARBEITSPLAN_NR = papk.ARBEITSPLAN_NR
group by papp.ARBEITSPLAN_NR
having sum(decode(BELEGUNGSEINHEIT_NR,3400,1,3500,1,3430,1)) != 3
This gives me 15112 records in return. The records contain less than 3 or greater than 3 BELEGUNGSEINHEIT_NR. But I get ARBEITSPLAN_NR containing more than 3 BELEGUNGSEINHEIT_NR. Example:
ARBEITSPLAN_NR =123456
BELEGUNGSEINHEIT_NR = 3500 BELEGUNGSEINHEIT_NR = 1234 BELEGUNGSEINHEIT_NR = 5678 BELEGUNGSEINHEIT_NR = 2468 BELEGUNGSEINHEIT_NR = 1357
I'd like to join the 2 select statements of:
select papp.ARBEITSPLAN_NR,sum(papp.BELEGUNGSEINHEIT_NR)
from w100.papp,w100.papk
where papp.ARBEITSPLAN_NR = papk.ARBEITSPLAN_NR
group by papp.ARBEITSPLAN_NR
having count(BELEGUNGSEINHEIT_NR) = 3
BELEGUNGSEINHEIT_NR
Using the output of the above query I'd like to query for those ARBEITSPLAN_NR containing only BELEGUNGSEINHEIT_NR (3500,3400,3430). Received on Mon Feb 21 2005 - 03:20:05 CST
![]() |
![]() |