Say I have the following table:
ID Value
-- ----
1 1
1 1
1 0
2 1
2 1
let us take the ID of 1. I need to check that all of the ID’s that are 1 have a value of 1.
If not, I need to return ‘N/A’. In this case, since row 3 had a value of 0, I need to return ‘N/A’
select * from tbl1 where ID = 1 and value = 1
will not quite do it.
I know SQL has the ALL keyword but not sure how to use it in this case
1 Answer