SQL Functions & CASE · Question 4 · Easy
SQL Functions & CASE question 4
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 query return for rolls 1 and 3?
SELECT name, ABS(marks - 60)
FROM Student
WHERE roll IN (1, 3)
ORDER BY roll;
- Aarav, 22; Kabir, -15
- Aarav, 142; Kabir, 105
- Aarav, 22; Kabir, 15
- Aarav, 22
Answer and explanation
Answer: C. Aarav, 22; Kabir, 15
Explanation: ABS returns the distance from zero. 82 - 60 = 22 stays 22, and 45 - 60 = -15 becomes 15.
Previous: A CASE expression has no ELSE part, and for some row none of its WHEN… · Next: The string literal below has two spaces before Pune and two spaces after it…
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…
- 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…
- 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