Hi,
I have a table with a foreign key, status, code
I would like to select the groups with the same foreign key with one record having a code of 001 and status of 'incomplete' and all the rest HAS to have a status of 'completed'
id foreignkey code status
---------------------------------------------------------------------
01 --- 04 ------------- 009 --------- completed
02 --- 04 ------------- 009 --------- completed
03 --- 04 ------------- 009 --------- completed
04 --- 04 ------------- 009 --------- completed
05 --- 04 ------------- 009 --------- completed
06 --- 04 ------------- 009 --------- completed
07 --- 04 ------------- 009 --------- completed
08 --- 04 ------------- 001 --------- incomplete
Let's say that foreign key "04" has 8 records where 5 has a status of complete, 2 has a status of 'Unknown' and 1 with 'Incomplete'. Then the query should not return this group.
Only if one status is 'incomplete' with code of 001 and ALL the rest is 'completed' status
I'll be running this in mysql, Thanks, Appreciate the help.