I want to select a row (that appears multiple times) from a table ONLY if the column ‘WRONG’ never reads “YES”.That means if the row exists 100 times and only one time WRONG=yes, then do no display ANY rows in the result.
*And if possible no variables and while loops please. If it can’t be done, then go ahead and post a solution with a variable.
Here is an example of table structure:
table 1
USER--WRONG--otherColumns
bob data
bob data
bob data
bob data
bob data
bob YES data
bob data
bob data
jon data
RESULT should be:
jon (because one time Wrong was equal to yes for the user bob)
This code ofcourse doesn’t omit all bobs. Only one is omitted:
SELECT USER FROM table1 WHERE wrong <> 'yes'
1 Answer