OA Exams
Which SQL function is used to find the highest value in a column?
a) MIN()b) MAX()c) SUM()d) AVERAGE()
Correct Answer: b) MAX()
Explanation: The MAX() function retrieves the highest value from a specified column in SQL.
Which SQL clause is used to group rows that have the same values in specified columns?
a) ORDER BYb) GROUP BYc) HAVINGd) WHERE
Correct Answer: b) GROUP BY
Explanation: The GROUP BY clause groups rows that share the same values in the specified columns, often used with aggregate functions.
Which SQL command is used to remove duplicates from a result set?
a) DISTINCTb) UNIQUEc) GROUP BYd) HAVING
Correct Answer: a) DISTINCT
Explanation: The DISTINCT keyword is used to return only unique records from the result set, eliminating duplicates.
Which SQL function would you use to count the number of non-NULL entries in a column?
a) TOTAL()b) COUNT()c) SUM()d) LENGTH()
Correct Answer: b) COUNT()
Explanation: The COUNT() function counts the number of non-NULL entries in a specified column.
Which clause is used to specify the order of the result set in SQL?
a) SORT BYb) ORDER BYc) GROUP BYd) ARRANGE BY
Correct Answer: b) ORDER BY
Explanation: The ORDER BY clause is used to sort the result set in ascending or descending order based on one or more columns.
Which SQL command is used to remove a user from a database?
a) DELETE USERb) REMOVE USERc) DROP USERd) DISABLE USER
Correct Answer: c) DROP USER
Explanation: The DROP USER command is used to permanently remove a user from the database management system.
Which SQL function is used to replace a substring with another string?
a) SUBSTITUTE()b) REPLACE()c) CHANGE()d) TRANSFORM()
Correct Answer: b) REPLACE()
Explanation: The REPLACE() function is used to substitute occurrences of a specified substring with a new string in SQL.
Which SQL keyword is used to specify the criteria for data retrieval in a SELECT statement?
a) CONDITIONb) WHEREc) HAVINGd) FILTER
Correct Answer: b) WHERE
Explanation: The WHERE clause is used to specify the criteria that must be met for records to be included in the result set of a SELECT statement.
What is a subquery in SQL?
a) A query that modifies datab) A query nested inside another queryc) A command that creates a new tabled) A function that summarizes data
Correct Answer: b) A query nested inside another query
Explanation: A subquery is a query embedded within another SQL query, often used to provide data for the outer query.
Which SQL function is used to extract a portion of a string?
a) SUBSTRING()b) SPLIT()c) TRIM()d) CONCAT()
Correct Answer: a) SUBSTRING()
Explanation: The SUBSTRING() function extracts a specific portion of a string based on the starting position and length specified.