Given 2 tables.
PR
prnum | col2 | col3
-------------------------
1001 | Khar | 5
2002 | SantaCruz | 3
3200 | Sion | 2
4321 | VT | 1
and
PRLine
prnum | prlinenum | status
------------------------------
1001 | 1 | INWILLCALL
1001 | 2 | ORDERED
2002 | 1 | ORDERED
2002 | 2 | ORDERED
2002 | 3 | ORDERED
3200 | 1 | INWILLCALL
3200 | 2 | INWILLCALL
I would like to select all the PRNUM's from PR table, where ALL of its corresponding records contained in PRLINE table have status of INWILLCALL.
In the tables above, only PRNUM 3200 should be returned.
so far, I have:
select * from PR WHERE
status not in ('CAN','CLOSED','COMP','DRAFT')
and prnum in (select prnum from prline where status = 'INWILLCALL');
which is obviously wrong.
Can someone help please ?
Thank you