SELECT, WHERE & ORDER BY · Question 15 · Medium
SELECT, WHERE & ORDER BY question 15
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 txn_id values does this query return?
SELECT txn_id
FROM Payments
WHERE status <> 'FAILED'
AND amount NOT BETWEEN 100 AND 800
ORDER BY txn_id;
- 4; 5
- 3; 4; 5
- 4
- 2; 4; 5; 7
Answer and explanation
Answer: A. 4; 5
Explanation: Payments 1, 3, 4, 5 and 6 are not FAILED. NOT BETWEEN 100 AND 800 excludes 100 to 800 inclusive, so 250, 800 and 450 go out, leaving 1200 (txn 4) and 60 (txn 5).
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 |…
- 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 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…
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
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