Advanced SQL queries and functions MCQs in DBMS
MCQs on Advanced SQL Queries and Functions in DBMS
- Which SQL clause is used to restrict the rows returned by a query based on a specified condition?
- a) SELECT
- b) WHERE
- c) FROM
- d) GROUP BY
Answer: b) WHERE
- What does the SQL function
NVL(expr1, expr2)
do?- a) Returns expr1 if it is not null, otherwise returns expr2.
- b) Returns the sum of expr1 and expr2.
- c) Returns true if expr1 equals expr2.
- d) Returns expr1 if it is equal to expr2, otherwise null.
Answer: a) Returns expr1 if it is not null, otherwise returns expr2.
- Which SQL function is used to remove leading and trailing spaces from a string?
- a) SUBSTR
- b) REPLACE
- c) TRIM
- d) INSTR
Answer: c) TRIM
- What is the purpose of the
HAVING
clause in SQL?- a) To filter rows before the grouping operation.
- b) To filter rows after the grouping operation.
- c) To join two tables.
- d) To sort the result set.
Answer: b) To filter rows after the grouping operation.
- Which of the following SQL statements is used to retrieve unique values from a column?
- a) SELECT DISTINCT column_name FROM table_name;
- b) SELECT UNIQUE column_name FROM table_name;
- c) SELECT DIFFERENT column_name FROM table_name;
- d) SELECT DISTINCT * FROM table_name;
Answer: a) SELECT DISTINCT column_name FROM table_name;
- What does the
COALESCE
function do in SQL?- a) Returns the first non-null value in the list.
- b) Concatenates two strings.
- c) Calculates the average of a list of numbers.
- d) Replaces a substring within a string.
Answer: a) Returns the first non-null value in the list.
- Which SQL function is used to count the number of rows in a table?
- a) SUM
- b) COUNT
- c) AVG
- d) MAX
Answer: b) COUNT
- Which SQL keyword is used to combine the results of two queries, eliminating duplicate rows?
- a) JOIN
- b) UNION
- c) INTERSECT
- d) EXCEPT
Answer: b) UNION
- What is the result of the following SQL query:
SELECT MOD(15, 4)
?- a) 3
- b) 4
- c) 2
- d) 1
Answer: a) 3
- Which SQL function is used to convert a string to uppercase?
- a) LOWER
- b) INITCAP
- c) UPPER
- d) LCASE
Answer: c) UPPER
- What is the purpose of the
CASE
statement in SQL?- a) To perform conditional logic in SQL queries.
- b) To join two tables.
- c) To create a new table.
- d) To update a table.
Answer: a) To perform conditional logic in SQL queries.
- Which of the following SQL functions can be used to find the current date and time?
- a) CURDATE()
- b) GETDATE()
- c) SYSDATE()
- d) All of the above
Answer: d) All of the above
- Which SQL clause is used to sort the result set?
- a) ORDER BY
- b) GROUP BY
- c) SORT BY
- d) ARRANGE BY
Answer: a) ORDER BY
- Which SQL function returns the length of a string?
- a) LENGTH
- b) CHAR_LENGTH
- c) LEN
- d) All of the above
Answer: d) All of the above
- What does the
ROUND
function do in SQL?- a) Truncates a number to the nearest integer.
- b) Rounds a number to a specified number of decimal places.
- c) Returns the square root of a number.
- d) Returns the absolute value of a number.
Answer: b) Rounds a number to a specified number of decimal places.
- What is the result of the following SQL query:
SELECT CONCAT('SQL', ' ', 'Tutorial')
?- a) ‘SQL Tutorial’
- b) ‘SQLTutorial’
- c) ‘SQL, Tutorial’
- d) ‘SQL-Tutorial’
Answer: a) ‘SQL Tutorial’
- Which of the following SQL clauses is used to combine rows from two or more tables based on a related column?
- a) WHERE
- b) JOIN
- c) GROUP BY
- d) ORDER BY
Answer: b) JOIN
- Which SQL function is used to extract a substring from a string?
- a) REPLACE
- b) SUBSTRING or SUBSTR
- c) TRIM
- d) CONCAT
Answer: b) SUBSTRING or SUBSTR
- What does the
DATEDIFF
function do in SQL?- a) Returns the difference between two date values.
- b) Adds a specified number of days to a date.
- c) Returns the current date.
- d) Formats a date value.
Answer: a) Returns the difference between two date values.
- Which SQL function is used to find the largest value in a column?
- a) MAX
- b) MIN
- c) AVG
- d) COUNT
Answer: a) MAX
More MCQs Of Database Systems
- Database Models MCQs in DBMS
- Relational Database Model MCQs in DBMS
- SQL (Structured Query Language) MCQs in DBMS
- Database Design MCQs in DBMS
- Database Management System Architecture MCQs in DBMS
- Storage and File Structure MCQs in DBMS
- Query Processing and Optimization MCQs in DBMS
- Database Transaction Management MCQs in DBMS
- Database Security and Authorization MCQs in DBMS
- Backup and Recovery MCQs in DBMS
- Distributed Databases MCQs in DBMS
- SET 1: database design mcqs (database design mcqs )
- SET 2: database mcqs with answers pdf (database mcqs with answers pdf )
- SET 3: modern database management 12th edition mcqs (modern database management 12th edition mcqs)
- SET 4: database systems mcqs (database systems mcqs)
- SET 5: dbms mcqs (dbms mcqs )
- SET 6: dbms mcqs with answers (dbms mcqs with answers)
- SET 7: solved mcqs of dbms (solved mcqs of dbms)
- SET 8: dbms mcqs with answers pdf(dbms mcqs with answers pdf)
- SET 9: relational database management system mcqs(relational database management system mcqs)
- SET 10: solved mcqs of database management system(solved mcqs of database management system)
- SET 11: basic database mcqs pdf (basic database mcqs pdf)
- SET 12: relational database management system mcqs (relational database management system mcqs )
- SET 13: database mcqs online test (database mcqs online test)
- SET 14: database interview questions mcqs (database interview questions mcqs)
- SET 15: database developer mcqs (database developer mcqs)
- SET 16: database Repeated mcqs (database Repeated mcqs)
- SET 17: Database mcqs PPSC (Database mcqs PPSC)
- SET 18: Database mcqs FPSC (Database mcqs FPSC)
- SET 19: DBMS mcqs FPSC (DBMS mcqs FPSC)
New Arrival