SELECT, WHERE & ORDER BY · Question 4 · Easy

SELECT, WHERE & ORDER BY question 4

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

Which payers does this query return, in order?

SELECT payer
FROM Payments
WHERE status = 'SUCCESS' AND amount > 500
ORDER BY txn_id;
  1. Farhan; Farhan; Gauri; Lakshmi
  2. Farhan; Gauri
  3. Lakshmi; Farhan; Gauri; Gauri
  4. Gauri
Answer and explanation

Answer: B. Farhan; Gauri

Explanation: AND needs both conditions to be true. The successful payments are 1, 3, 4 and 5, and of these only 3 (Farhan, 800) and 4 (Gauri, 1200) are above 500.

Previous: Table Products: pid | name | category | price | stock 1 | Kurta | Clothing |… · Next: Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…

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