For example,
For example: table name: students
sno | name | mark |
---|---|---|
1 | Sachin | 39 |
2 | Dravid | 90 |
3 | Kohli | 30 |
4 | Ganguly | 66 |
Output: Pass mark is above 40
sno | name | result |
---|---|---|
1 | Sachin | Fail |
2 | Sachin | Pass |
3 | Kohli | Fail |
4 | Ganguly | Pass |
Query:
SELECT sno, name, CASE WHEN mark >= 40 THEN 'Pass' ELSE 'Fail' END AS Result FROM student
No comments:
Post a Comment