SQL Functions & CASE · Question 13 · Medium
Table Visitor: id | city 1 | pune 2 | Delhi 3 | PUNE 4 | delhi 5 | Pune City names were typed in mixed case. What does this query return?
SELECT UPPER(city), COUNT(*)
FROM Visitor
GROUP BY UPPER(city)
ORDER BY UPPER(city);
- DELHI, 2; PUNE, 3
- DELHI, 1; PUNE, 1
- DELHI, 2; PUNE, 1
- DELHI, 5
Answer and explanation
Answer: A. DELHI, 2; PUNE, 3
Explanation: UPPER is applied to each row before grouping, so pune, PUNE and Pune all become PUNE (3 rows) and Delhi and delhi become DELHI (2 rows).
Previous: Table Payment: id | mode | amount | status 1 | UPI | 500 | SUCCESS 2 | CARD |… · Next: Table Salary: emp | basic | bonus Nikhil | 30000 | 5000 Ojas | 40000 | NULL…
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 Payment: id | mode | amount | status 1 | UPI | 500 | SUCCESS 2 | CARD |…
- Table Payment: id | mode | amount | status 1 | UPI | 500 | SUCCESS 2 | CARD |…
- Table Salary: emp | basic | bonus Nikhil | 30000 | 5000 Ojas | 40000 | NULL…
- Which statement about the SQL CASE expression is correct?
- 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 |…
- Table Payment: id | mode | amount | status 1 | UPI | 500 | SUCCESS 2 | CARD |…
- 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…
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