0% found this document useful (0 votes)
27 views7 pages

SQL MCQ All Questions

Uploaded by

onkarghorpade18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views7 pages

SQL MCQ All Questions

Uploaded by

onkarghorpade18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

SQL Multiple Choice Questions (Complete Set)

1. Which SQL statement is used to retrieve data from a database?

a) SELECT

b) GET

c) OPEN

d) RETRIEVE

Answer: a) SELECT

2. Which clause is used to filter records in SQL?

a) WHERE

b) FILTER

c) HAVING

d) ORDER

Answer: a) WHERE

3. Which SQL keyword is used to sort the result set?

a) ORDER BY

b) SORT BY

c) SORT

d) ORDER

Answer: a) ORDER BY

4. What does the COUNT() function do in SQL?

a) Counts all rows

b) Counts all columns

c) Counts null values

d) Counts unique records


Answer: a) Counts all rows

5. Which SQL function is used to find the highest value in a column?

a) MAX()

b) HIGHEST()

c) GREATEST()

d) TOP()

Answer: a) MAX()

6. What does the SQL statement SELECT DISTINCT do?

a) Selects unique columns

b) Selects unique records

c) Selects unique tables

d) Selects unique databases

Answer: b) Selects unique records

7. Which SQL clause is used to group records that have the same values?

a) GROUP BY

b) SORT BY

c) ORDER BY

d) HAVING

Answer: a) GROUP BY

8. Which SQL keyword is used to create a new table?

a) ADD TABLE

b) CREATE TABLE

c) NEW TABLE
d) INSERT TABLE

Answer: b) CREATE TABLE

9. In SQL, which operator is used to search for a specified pattern in a column?

a) LIKE

b) PATTERN

c) MATCH

d) SEARCH

Answer: a) LIKE

10. Which SQL function is used to count the number of unique values in a column?

a) COUNT(ALL)

b) COUNT()

c) COUNT(DISTINCT)

d) COUNT(UNIQUE)

Answer: c) COUNT(DISTINCT)

11. What does the INNER JOIN clause do in SQL?

a) Returns all records from both tables

b) Returns records with matching values in both tables

c) Returns records with unmatched values

d) Combines columns from both tables

Answer: b) Returns records with matching values in both tables

12. In SQL, the HAVING clause is used with which statement?

a) ORDER BY

b) WHERE
c) GROUP BY

d) SELECT

Answer: c) GROUP BY

13. Which statement is used to delete data from a database?

a) DELETE

b) REMOVE

c) DROP

d) CLEAR

Answer: a) DELETE

14. Which SQL statement is used to update existing data in a table?

a) MODIFY

b) UPDATE

c) ALTER

d) CHANGE

Answer: b) UPDATE

15. What is the result of SELECT COUNT(*)?

a) Total number of records in a table

b) Total number of columns in a table

c) Total number of rows excluding nulls

d) Total number of tables

Answer: a) Total number of records in a table

16. What does the LEFT JOIN operation return?

a) Only matching records from both tables


b) All records from the left table, and matching records from the right

c) All records from both tables

d) Only non-matching records

Answer: b) All records from the left table, and matching records from the right

17. Which SQL function is used to round values?

a) ROUND()

b) TRUNCATE()

c) FLOOR()

d) CEIL()

Answer: a) ROUND()

18. In SQL, which command is used to remove a table from a database?

a) DROP TABLE

b) DELETE TABLE

c) REMOVE TABLE

d) CLEAR TABLE

Answer: a) DROP TABLE

19. How can you select records where a column has NULL values?

a) WHERE column = NULL

b) WHERE column IS NULL

c) WHERE column != NULL

d) WHERE column NOT NULL

Answer: b) WHERE column IS NULL

20. Which function would you use to calculate the difference between two dates?
a) DATEDIFF()

b) DATECALC()

c) TIMEDIFF()

d) DIFFDATE()

Answer: a) DATEDIFF()

21. Which clause is required to use aggregate functions like SUM() with conditions?

a) GROUP BY

b) HAVING

c) ORDER BY

d) WHERE

Answer: b) HAVING

22. Which SQL statement will return the maximum salary from an 'employees' table?

a) SELECT MAX(salary) FROM employees;

b) SELECT salary FROM employees WHERE MAX;

c) SELECT MAXIMUM(salary) FROM employees;

d) SELECT salary FROM employees ORDER BY MAX;

Answer: a) SELECT MAX(salary) FROM employees;

23. What will be the output if you use WHERE salary BETWEEN 3000 AND 5000?

a) Records with salary exactly 3000 or 5000

b) Records with salary above 3000 and below 5000

c) Records with salary between 3000 and 5000 inclusive

d) No records

Answer: c) Records with salary between 3000 and 5000 inclusive


24. In SQL, how do you rename a column in a result set?

a) By using AS

b) By using RENAME

c) By using CHANGE

d) By using ALIAS

Answer: a) By using AS

25. Which SQL statement returns the number of rows affected by the last SQL statement?

a) ROWCOUNT()

b) LASTROWCOUNT()

c) ROW_AFFECTED()

d) COUNT()

Answer: a) ROWCOUNT()

You might also like