SELECT, WHERE & ORDER BY · Question 11 · Medium
SELECT, WHERE & ORDER BY question 11
Table Payments:
txn_id | payer | app | amount | status
1 | Farhan | GPay | 250 | SUCCESS
2 | Lakshmi | PhonePe | 1200 | FAILED
3 | Farhan | Paytm | 800 | SUCCESS
4 | Gauri | GPay | 1200 | SUCCESS
5 | Lakshmi | GPay | 60 | SUCCESS
6 | Harish | PhonePe | 450 | PENDING
7 | Gauri | Paytm | 1200 | FAILED
How many rows does this query return?
SELECT DISTINCT payer, amount
FROM Payments;
- 4 rows
- 5 rows
- 6 rows
- 7 rows
Answer and explanation
Answer: C. 6 rows
Explanation: DISTINCT applies to the whole (payer, amount) pair, not to each column separately. Only (Gauri, 1200) occurs twice, so 7 rows reduce to 6.
Previous: Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |… · Next: Table Products: pid | name | category | price | stock 1 | Kurta | Clothing |…
Practise select, where & order by
Try a fresh set of select, where & order by questions with an explanation after every answer, free and without signing up: SELECT, WHERE & ORDER BY practice. Or sit a full placement mock test.
More select, where & order by questions
- Table Products: pid | name | category | price | stock 1 | Kurta | Clothing |…
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
- Table Products: pid | name | category | price | stock 1 | Kurta | Clothing |…
- A query has the clauses SELECT, FROM, WHERE, ORDER BY and LIMIT. In which…
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
- Table Payments: txn_id | payer | app | amount | status 1 | Farhan | GPay | 250…
- Table Products: pid | name | category | price | stock 1 | Kurta | Clothing |…
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
- Table Payments: txn_id | payer | app | amount | status 1 | Farhan | GPay | 250…
More sql practice
SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge