SQL MCQ All Questions
SQL MCQ All Questions
a) SELECT
b) GET
c) OPEN
d) RETRIEVE
Answer: a) SELECT
a) WHERE
b) FILTER
c) HAVING
d) ORDER
Answer: a) WHERE
a) ORDER BY
b) SORT BY
c) SORT
d) ORDER
Answer: a) ORDER BY
a) MAX()
b) HIGHEST()
c) GREATEST()
d) TOP()
Answer: a) MAX()
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
a) ADD TABLE
b) CREATE TABLE
c) NEW TABLE
d) INSERT TABLE
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)
a) ORDER BY
b) WHERE
c) GROUP BY
d) SELECT
Answer: c) GROUP BY
a) DELETE
b) REMOVE
c) DROP
d) CLEAR
Answer: a) DELETE
a) MODIFY
b) UPDATE
c) ALTER
d) CHANGE
Answer: b) UPDATE
Answer: b) All records from the left table, and matching records from the right
a) ROUND()
b) TRUNCATE()
c) FLOOR()
d) CEIL()
Answer: a) ROUND()
a) DROP TABLE
b) DELETE TABLE
c) REMOVE TABLE
d) CLEAR TABLE
19. How can you select records where a column has NULL values?
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?
23. What will be the output if you use WHERE salary BETWEEN 3000 AND 5000?
d) No records
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()