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;
  1. 4 rows
  2. 5 rows
  3. 6 rows
  4. 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

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