I have a table with following structure:
Name | Subject | ExamType | Passed |
---|---|---|---|
Bryan | Science | Theory | True |
Bryan | Science | Practical | False |
Joe | Science | Theory | True |
Joe | Science | Practical | True |
Jill | Science | Theory | False |
Jill | Science | Practical | False |
Jack | Science | Theory | False |
Jack | Science | Practical | True |
We need to apply OR condition, so that if a student has passed in EITHER Theory OR Practical, he/she is considered Pass (i.e. True). So we need the following result:
Name | Passed |
---|---|
Bryan | True |
Joe | True |
Jill | False |
Jack | True |
How to apply condition across the rows to achieve the above result?
I tried using distinct and CASE but cant put my head around how to scan across multiple rows.
Try this
SELECT
Name,
MAX(Passed) AS Passed
FROM
YourTableName
GROUP BY
Name;