I have a table with 2 columns, following is my table structure
referral_id | status
531 | 0
531 | 0
531 | 3
530 | 3
529 | 3
528 | 3
527 | 3
527 | 0
527 | 0
523 | 2
523 | 0
523 | 3
522 | 3
522 | 3
522 | 3
522 | 3
511 | 3
My expected output is
referral_id | status
530 | 3
529 | 3
528 | 3
522 | 3
511 | 3
The 1st column referral_id can have multiple tuples with same id (see referral_id's 531 and 527). I need to make sure that tuples with same referral_id get eliminated if all of their corresponding "status" are NOT 3. If all of the corresponding "status" are 3 then I need to apply GROUP BY to get that referral_id(s) in result. "status" column can have values from 1 to 4, but I just need to look for 3. So how can I achieve this result ?
remove if ALL are not 3? Because since 527 has a 3, that would mean 527 would be in the results. Or do you meanremove if not all are 3?