SELECT, WHERE and DISTINCT MCQs: 12 Solved SQL Questions with Explanations
Test the SQL basics that decide columns, filter rows and remove duplicates. Attempt 12 MCQs, then use each short solution to diagnose the exact rule involved.
KnowledgeGate Team
Exam prep & CS education

SELECT returns columns, WHERE keeps rows, and DISTINCT removes duplicate rows. About 50 practice questions focus on choosing columns, filtering rows and removing duplicate results in SELECT, WHERE and DISTINCT. Attempt each one before reading why the answer wins and its distractors fail.
SELECT, WHERE and DISTINCT: the three rules before the MCQs
SQL part | Job | Quick reading rule |
|---|---|---|
| Chooses the output columns | SQL |
| Filters input rows | SQL |
| Removes duplicate result rows | It acts after the selected columns have been projected |
For each trace, read FROM, apply WHERE, project SELECT, then apply DISTINCT if present. SQL syntax, Boolean logic, predicates, cardinality and relational algebra shape how SELECT, WHERE and DISTINCT work.
DISTINCT and duplicate handling: Questions 1-3
Q1. DISTINCT
Accenture 2025.
“In SQL, which command is used to SELECT only one copy of each set of duplicable rows”
A. SELECT DISTINCTB. SELECT UNIQUEC. SELECT DIFFERENTD. All of the above
Answer: A. Plain SELECT keeps duplicates; DISTINCT removes identical projected rows. DIFFERENT is invalid, and the question asks for the standard command rather than a vendor synonym.
Q2. DISTINCT on MYSTUDENT (question unavailable; see course hub)
Navodaya Vidyalaya Samiti 2022.
The MYSTUDENT table is shown below. Which SQL command displays each distinct SEC value?
ROLLNO | NAME | SEC | MARKS |
|---|---|---|---|
80105 | MARIA | A | 83.0 |
80108 | AMAR | B | 44.0 |
80109 | MANPREET | A | 92.0 |
80112 | SAMEER | A | 81.0 |
80115 | AKBAR | B | NULL |
A. SELECT DISTINCT SEC FROM MYSTUDENT;B. SELECT DIFFERENT SEC FROM MYSTUDENT;C. SELECT ALL SEC FROM MYSTUDENT;D. SELECT UNIQUE SEC FROM MYSTUDENT;
Answer: A. Projecting SEC gives A, B, A, A, B. DISTINCT leaves A, B, while ALL preserves duplicates.
Q3. DISTINCT self-join
UGC NET 2013.
“The SQL expression Select distinct T.branch_name from branch T, branch S where T.assets > S.assets and S.branch_city = "Mumbai" finds the names of”
A. All branches that have greater assets than some branch located in Mumbai.B. All branches that have greater assets than all branches in Mumbai.C. The branch that has greatest asset in Mumbai.D. Any branch that has greater assets than any branch in Mumbai.
Answer: A.S ranges over Mumbai branches, and T qualifies if one has lower assets. DISTINCT removes repeated names; nothing requires T to beat every Mumbai branch.
WHERE syntax and Boolean logic: Questions 4-6
Q4. WHERE operators
Bihar STET 2025.
“Which of the following is not a valid relational operator used with WHERE clause in SQL?”
A. >B. <=C. =>D. <>
Answer: C. SQL uses >=, so => is invalid. The not-equal operator <> is valid. The same malformed-operator test appears in SQL Datatypes, Operators and NULL MCQs, where it tests operator taxonomy. Here it tests whether you can reject a malformed comparison inside a WHERE clause.
Q5. Missing FROM
UP Police 2013.
“Which of the following statement contains an error?”
A. Select * from EMP where EMPID = 15;B. Select EMPID from EMP where EMPID = 15;C. Select EMPID from EMP;D. Select EMPID where EMPID = 15 and LASTNAME = 'Singh';
Answer: D.EMPID and LASTNAME have no FROM source. Some systems allow literals without FROM, but base-table columns need their table.
Q6. OR precedence
TCS 2025.
“Find the city names, along with their condition and temperature, from the 'weather' table where the condition is 'sunny' or 'cloudy' but the temperature is at least 60.”
A. SELECT city, temperature, condition FROM weather WHERE condition = 'cloudy' AND condition = 'sunny' OR temperature >= 60B. SELECT city, temperature, condition FROM weather WHERE condition = 'cloudy' OR condition = 'sunny' OR temperature >= 60C. SELECT city, temperature, condition FROM weather WHERE (condition = 'sunny' OR condition = 'cloudy') AND temperature >= 60D. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' AND temperature >= 60
Answer: C. Parentheses group sunny or cloudy before applying the temperature test. A and B admit unintended rows; D requires both conditions at once.
WHERE predicate tools: Questions 7-9
Q7. LIKE and NOT LIKE
IBPS 2024.
“Which of the following SQL queries correctly selects records where the First_Name contains a specific pattern, the Last_Name also matches a pattern using LIKE, and the City does not match a given pattern using NOT LIKE?”
A. SELECT * FROM Employee WHERE First_Name LIKE '%A%' AND Last_Name LIKE '%K%' AND City NOT LIKE '%Delhi%';B. SELECT * FROM Employee WHERE First_Name = '%A%' AND Last_Name = '%K%' AND City != '%Delhi%';C. SELECT * FROM Employee WHERE First_Name IN '%A%' AND Last_Name IN '%K%' AND City NOT IN '%Delhi%';D. SELECT * FROM Employee WHERE First_Name LIKE '%A%' OR Last_Name LIKE '%K%' OR City NOT LIKE '%Delhi%';E. SELECT * FROM Employee WHERE First_Name NOT LIKE '%A%' AND Last_Name LIKE '%K%' AND City LIKE '%Delhi%';
Answer: A.%A% and %K% match anywhere, while NOT LIKE '%Delhi%' excludes cities containing Delhi. All tests require AND; equality and IN do not treat % as a wildcard.
Q8. IN
IBPS 2023.
“Which SQL operator is used to filter rows by checking whether a value matches any value in a specified list?”
A. BETWEENB. INC. LIKED. EXISTSE. DISTINCT
Answer: B.WHERE dept IN ('CS', 'IT', 'ECE') accepts any listed match. BETWEEN handles ranges, LIKE patterns, EXISTS subquery rows, and DISTINCT duplicates.
Q9. BETWEEN (question unavailable; see course hub)
DSSSB 2018.
“Consider the following Oracle SQL query: SELECT * FROM Products WHERE Price BETWEEN 10 AND 20; Which of the following is the correct interpretation of this query?”
A. Select all products whose price is greater than 10 but less than 20B. Select all products whose price is greater than or equal to 10 but less than 20C. Select all products whose price is greater than 10 but less than or equal to 20D. Select all products whose price is greater than or equal to 10 but less than or equal to 20
Answer: D.BETWEEN means Price >= 10 AND Price <= 20. Thus 10, 15 and 20 qualify; 9.99 and 20.01 do not.
Trace the result set: Questions 10-11

Q10. Recurrence
GATE 2011.
Consider a database table T containing two columns X and Y each of type integer. After the creation of the table, one record (X=1, Y=1) is inserted in the table. Let MX and MY denote the respective maximum values of X and Y among all records in the table at any point in time. Using MX and MY, new records are inserted in the table 128 times with X and Y values being MX+1, 2*MY+1 respectively. It may be noted that each time after the insertion, values of MX and MY change. What will be the output of the following SQL query after the steps mentioned above are carried out?
SELECT Y FROM T WHERE X=7;A. 127B. 255C. 129D. 257
Answer: A. Iterating X = MX+1 and Y = 2*MY+1 from (1,1) gives:
(1,1), (2,3), (3,7), (4,15), (5,31), (6,63), (7,127)
The sixth insertion creates X=7. Independently, Y = 2^(n+1) - 1, so n=6 gives 128 - 1 = 127.
Q11. Set union
UGC NET 2015.
Consider the following three SQL queries on the people table:
(a) SELECT Name FROM people WHERE Age > 21;
(b) SELECT Name FROM people WHERE Height > 180;
(c) SELECT Name FROM people WHERE Age > 21 OR Height > 180;
Queries (a) and (b) return 10 rows and 7 rows respectively. What is one possible row count for query (c)?
A. 3B. 7C. 10D. 21
Answer: C.|A ∪ B| = 10 + 7 - |A ∩ B|, so the union ranges from 10 to 17. Ten occurs when all 7 height-matching rows are among the 10 age-matching rows.

Convert relational algebra into SQL: Question 12
Q12. Relational algebra
Coal India 2020.
Consider the following relational schema:
Sailors(sid, sname, rating, age)
Reserves(sid, bid, day)
Boats(bid, bname, color)
Which SQL query is equivalent to πsname((σcolor = 'red'(Boats)) ⋈ Reserves ⋈ Sailors)?
A. SELECT S.sname, S.rating FROM Sailors S, Reserves R WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = 'red'B. SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = 'red'C. SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND B.color = 'red'D. SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE R.bid = B.bid AND B.color = 'red'
Answer: B. Map πsname to SELECT S.sname, include three relations, two joins and the red filter. A adds a column and omits Boats B; C and D each omit a join.
SELECT, WHERE and DISTINCT MCQs: score map and next step
Score map: duplicate handling, Q1-Q3; syntax and Boolean grouping, Q4-Q6; predicates, Q7-Q9; tracing and cardinality, Q10-Q11; relational-algebra translation, Q12.
Write FROM, WHERE, SELECT, DISTINCT beside each trace. This set owns WHERE predicates and DISTINCT traces. For joins and subqueries, continue with SQL Query MCQs: 12 Solved (SELECT, Joins, Subqueries), or browse CS Fundamentals for Exams & Placements.
For the full exam sequence, use GATE Guidance by Sanchit Sir. For technical-interview revision, use CS Fundamentals for Placements by Sanchit Sir. Correct the rule behind each miss instead of memorising its answer letter.
Keep learning
DBMS SQL Query MCQs: 12 solved questions on SELECT, joins and subqueries
DBMS SQL query MCQs: 12 solved previous-year questions on SELECT and DISTINCT, inner and outer joins, GROUP BY and HAVING, and correlated subqueries.
SQL SELECT Basics: Syntax, Output, and Runnable Examples
Learn how SELECT shapes a result without changing stored data. Run one small table through column lists, aliases, arithmetic expressions, and DISTINCT.
SQL WHERE Clause and Filtering: Syntax, Operators, and Worked Examples
Learn SQL filtering on one runnable eight-row orders table. Trace WHERE conditions row by row, combine Boolean operators, handle NULL, and check exact results.
Third Normal Form (3NF) MCQs: 12 Solved Questions with Explanations
Solve 12 real 3NF exam MCQs with clear explanations, candidate-key closures, a raw-row decomposition, and the prime-attribute exception that separates 3NF from BCNF.





