General SQL XII
1.
What does the SQL statement 'SELECT MAX(price) FROM products WHERE category = 'Electronics';' do?
Deletes all rows from the 'Electronics' category in the products table
Counts the total number of products in the 'Electronics' category
Finds the highest price of products in the 'Electronics' category
Updates all rows in the 'Electronics' category in the products table
2.
Which SQL statement is used to calculate the average value of a numeric column?
SUM(column_name) / COUNT(column_name)
AVG TABLE table_name.column_name;
CALCULATE AVG(column_name) IN table_name;
SELECT AVG(column_name) FROM table_name;
3.
Which SQL statement is used to change the value of a column in an existing row?
ALTER table_name SET column_name = new_value WHERE condition;
CHANGE VALUE OF column_name TO new_value IN table_name WHERE condition;
MODIFY table_name SET column_name = new_value WHERE condition;
UPDATE table_name SET column_name = new_value WHERE condition;
4.
Which SQL statement is used to delete a table from the database along with its structure?
DROP TABLE table_name;
DELETE TABLE table_name;
REMOVE TABLE table_name;
ERASE TABLE table_name;
5.
Which SQL function is used to calculate the absolute value of a numeric expression?
SIGN()
MOD()
ABS()
POWER()
6.
What does the term 'Full Outer Join' mean in the context of SQL?
A method of searching for data by directly accessing the data pages
A type of JOIN that retrieves unmatched rows from both tables
Retrieves all rows when there is a match in either the left or right table
A method of sorting the result set
7.
Which SQL function is used to extract the day from a date?
DAY()
EXTRACT(DAY FROM date_column)
DATEPART(DAY, date_column)
TO_DAY(date_column)
8.
What is the purpose of the SQL keyword 'TRANSACTION' in a stored procedure?
Orders the result set in ascending or descending order
Marks the beginning of a transaction block
Performs arithmetic operations on the result set
Filters rows based on a condition after the GROUP BY clause
9.
Which SQL statement is used to grant execute permission on a stored procedure to a user?
GRANT EXECUTE ON procedure_name TO user_name;
ALLOW EXECUTION OF procedure_name TO user_name;
GRANT PERMISSION EXECUTE ON procedure_name FOR user_name;
GRANT EXECUTION TO user_name ON procedure_name;
10.
Which SQL function is used to convert a string to uppercase?
UPPER()
UCASE()
TO_UPPER()
CONVERT_UPPER()
11.
What is the purpose of the SQL keyword 'LEFT JOIN' in a SELECT statement?
Orders the result set in ascending or descending order
Combines the result sets of two SELECT statements, excluding duplicates
Retrieves all rows from the left table and matching rows from the right table
Filters rows based on a condition after the GROUP BY clause
12.
Which SQL function is used to find the position of a substring within a string?
SUBSTR_POS()
INDEXOF()
CHARINDEX()
STRING_POSITION()
13.
Which SQL statement is used to insert multiple rows into a table in a single statement?
MULTI INSERT INTO table_name VALUES (value1, value2), (value3, value4), ...;
INSERT VALUES (value1, value2), (value3, value4), ... INTO table_name;
INSERT INTO table_name VALUES (value1, value2), (value3, value4), ...;
ADD ROWS (value1, value2), (value3, value4), ... TO table_name;
14.
What does the SQL statement 'SELECT CONCAT_WS(', ', first_name, last_name) FROM employees;' do?
Deletes all rows from the employees table
Counts the total number of employees
Concatenates the first name and last name of employees with a comma and space in between
Updates all rows in the employees table
15.
Which SQL function is used to find the difference between two dates in days?
DATEDIFF()
DATE_DIFF()
DIFFDATE()
DAY_DIFF()
16.
What is the purpose of the SQL keyword 'ROLLUP' in a GROUP BY clause?
Performs arithmetic operations on the result set
Orders the result set in ascending or descending order
Generates subtotals and grand totals in the result set
Filters rows based on a condition after the GROUP BY clause
17.
What does the SQL statement 'SELECT COALESCE(column_name, 'Default Value') FROM table_name;' do?
Retrieves the first non-null expression among its arguments
Returns the column value if it is not null, otherwise returns 'Default Value'
Returns 'Default Value' if the column value is null, otherwise returns the column value
Counts the total number of rows
18.
Which SQL function is used to find the total number of rows in a table?
NUM_ROWS()
TOTAL_ROWS()
COUNT(*)
ROWS_COUNT()
19.
Which SQL statement is used to grant SELECT and INSERT permissions on a table to a user?
ALLOW SELECT, INSERT ON table_name FOR user_name;
GRANT SELECT, INSERT ON table_name TO user_name;
GRANT PERMISSION SELECT, INSERT ON table_name FOR user_name;
GRANT SELECT, INSERT TO user_name ON table_name;
20.
Which SQL function is used to calculate the average of a set of values, excluding the highest and lowest values?
AVG_EXCLUDE_EXTREMES()
AVERAGE_EXCLUDE_EXTREMES()
EXCLUDE_EXTREMES_AVG()
AVG() excluding extremes