SQL Questions and Answers – SQL Select Distinct

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Select Distinct”.

1. Which keyword is used in conjunction with DISTINCT keyword?
a) From
b) Select
c) Where
d) Group By
View Answer

Answer: b
Explanation: The distinct keyword is used in conjunction with select keyword. When we use distinct keyword, only the unique values are fetched.

2. Which SQL statement is used to return only different values?
a) Select Different
b) Select Unique
c) Select Distinct
d) Select
View Answer

Answer: c
Explanation: The SELECT DISTINCT statement is used to return only distinct values. The SELECT statement returns data without eliminating duplicates, whereas the rest are not SQL statements.

3. A column of a database table must not contain duplicate values.
a) True
b) False
View Answer

Answer: b
Explanation: Inside a database table, a column may contain many duplicate values. It is not mandatory that every column should have a unique value.
advertisement
advertisement

4. Which of the following SQL statement selects only unique values from ‘section’ column of table ‘school’?
a) SELECT section FROM school;
b) SELECT * FROM school;
c) SELECT DISTINCT section FROM school;
d) SELECT ALL section FROM school;
View Answer

Answer: c
Explanation: Distinct keyword along with Select clause returns only distinct values. All keyword when used with select clause returns all values without eliminating the duplicates. * Results all the fields of a table without eliminating duplicates.

5. When more than one expression is provided in the DISTINCT clause, the query will retrieve _________
a) Unique values for any one of the expression
b) Unique combinations for the expressions listed
c) All values for any one of the expression
d) All combinations for the expressions listed
View Answer

Answer: b
Explanation: When only one expression is provided in the DISTINCT clause, the query will return the unique values for that expression. When more than one expression is provided in the DISTINCT clause, the query will retrieve unique combinations for the expressions listed.

6. In SQL, the DISTINCT clause ignores NULL values.
a) True
b) False
View Answer

Answer: b
Explanation: In SQL, the DISTINCT clause doesn’t ignore NULL values. So when using the DISTINCT clause in SQL statement, our result set will include NULL as a distinct value.

7. DISTINCT clause considers NULL as ________
a) Zero value
b) A unique value
c) Some default value
d) A space character
View Answer

Answer: b
Explanation: A field with a NULL value is the one that has been left during record creation. SQL Distinct clause treats NULL as a unique value. So when using the DISTINCT clause in SQL statement, our result set will include NULL as a distinct value.
advertisement

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.