I'd like to check a column in a table if they have the same value.
ID School_Name Student Status
1 Virginia Alex 2
2 Virginia John 2
3 Wonderbow Devi 1
4 San Antonio Lucas 1
5 San Antonio Larsa 2
How to check the column status
if the value is 2
for each School_Name
. The output is some thing like this:
ID School_Name school_stat
1 Virginia TRUE
2 Wonderbow FALSE
3 San Antonio FALSE
So, if all student in each school name has the status of 2, the result is TRUE.
Current Query:
SELECT *,SUM(case when status > 1 then TRUE else FALSE end) as school_stat from t_school
The query giving wrong output though.