SQL Functions & CASE · Question 2 · Easy
SQL Functions & CASE question 2
Table Student:
roll | name | marks
1 | Aarav | 82
2 | Diya | 67
3 | Kabir | 45
4 | Meher | 91
5 | Rohan | 30
6 | Sneha | NULL
What does this CASE query return for rolls 3 and 5?
SELECT name,
CASE WHEN marks >= 40 THEN 'Pass' ELSE 'Fail' END
FROM Student
WHERE roll IN (3, 5)
ORDER BY roll;
- Kabir, Fail; Rohan, Fail
- Kabir, Pass; Rohan, Pass
- Kabir, Pass
- Kabir, Pass; Rohan, Fail
Answer and explanation
Answer: D. Kabir, Pass; Rohan, Fail
Explanation: Kabir has 45, which satisfies marks >= 40, so the THEN value Pass is used. Rohan has 30, the condition is false, and the ELSE value Fail is used.
Previous: Table Student: roll | name | marks 1 | Aarav | 82 2 | Diya | 67 3 | Kabir | 45… · Next: A CASE expression has no ELSE part, and for some row none of its WHEN…
Practise sql functions & case
Try a fresh set of sql functions & case questions with an explanation after every answer, free and without signing up: SQL Functions & CASE practice. Or sit a full placement mock test.
More sql functions & case questions
- Table Student: roll | name | marks 1 | Aarav | 82 2 | Diya | 67 3 | Kabir | 45…
- A CASE expression has no ELSE part, and for some row none of its WHEN…
- Table Student: roll | name | marks 1 | Aarav | 82 2 | Diya | 67 3 | Kabir | 45…
- The string literal below has two spaces before Pune and two spaces after it…
- Which standard SQL function converts a value from one data type to another…
- What does this query return?
- Table Student: roll | name | marks 1 | Aarav | 82 2 | Diya | 67 3 | Kabir | 45…
- Table Student: roll | name | marks 1 | Aarav | 82 2 | Diya | 67 3 | Kabir | 45…
- Table Student: roll | name | marks 1 | Aarav | 82 2 | Diya | 67 3 | Kabir | 45…
- Table Payment: id | mode | amount | status 1 | UPI | 500 | SUCCESS 2 | CARD |…
More sql practice
UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge