img
SQL - II

SQL is a programming language for managing relational databases. It handles data storage, retrieval, and manipulation efficiently.

Last updated on:- 7th June 2023


1.
What is a correlated subquery in SQL ?
A subquery that is independent of the outer query
A subquery that refers to a column from the outer query
A subquery that returns multiple rows
A subquery that is used with the EXISTS operator

A correlated subquery is a subquery that refers to a column from the outer query, allowing the inner query to be dependent on the outer query's results.


2.
What is the purpose of the SQL HAVING clause ?
To filter records based on a specified condition
To combine rows from two or more tables
To sort the result set in ascending or descending order
To filter groups based on a specified condition

The HAVING clause is used to filter groups based on a specified condition in SQL. It is typically used in combination with the GROUP BY clause.


3.
Which SQL statement is used to insert new records into a table ?
INSERT
UPDATE
SELECT
DELETE

The INSERT statement is used to insert new records into a table in SQL.


4.
What is the purpose of the SQL UNION operator ?
To combine rows from two or more tables
To filter records based on a specified condition
To sort the result set in ascending or descending order
To perform mathematical calculations on numeric columns

The UNION operator is used to combine rows from two or more tables into a single result set in SQL.


5.
Which SQL function is used to convert a value to a different data type ?
SUM
AVG
CONVERT
MAX

The CONVERT function is used to convert a value to a different data type in SQL.


6.
What is the purpose of the SQL CASE statement ?
To combine rows from two or more tables
To filter records based on a specified condition
To perform mathematical calculations on numeric columns
To conditionally perform an action based on specified criteria

The CASE statement is used to conditionally perform an action based on specified criteria in SQL.


7.
Which SQL operator is used to select all records from a table ?
AND
OR
NOT
ALL

The ALL operator is used to select all records from a table in SQL.


8.
What is the purpose of the SQL EXISTS operator ?
To combine rows from two or more tables
To filter records based on a specified condition
To check if a subquery returns any rows
To perform mathematical calculations on numeric columns

The EXISTS operator is used to check if a subquery returns any rows in SQL.


9.
Which SQL statement is used to update existing records in a table ?
INSERT
UPDATE
SELECT
DELETE

The UPDATE statement is used to update existing records in a table in SQL.


10.
What is the purpose of the SQL ORDER BY clause ?
To filter records based on a specified condition
To combine rows from two or more tables
To sort the result set in ascending or descending order
To perform mathematical calculations on numeric columns

The ORDER BY clause is used to sort the result set in ascending or descending order based on one or more columns in SQL.


11.
What is the purpose of the SQL GROUP BY clause ?
To combine rows from two or more tables
To filter records based on a specified condition
To sort the result set in ascending or descending order
To group rows with the same values into summary rows

The GROUP BY clause is used to group rows with the same values into summary rows in SQL.


12.
Which SQL operator is used to check if a value is NULL ?
IS
LIKE
NOT
BETWEEN

The IS operator is used to check if a value is NULL in SQL.


13.
Which SQL keyword is used to specify a condition to be met for the result set ?
SELECT
WHERE
FROM
ORDER BY

The WHERE keyword is used to specify a condition to be met for the result set in SQL.


14.
Which SQL function is used to find the highest value in a column ?
SUM
AVG
COUNT
MAX

The MAX function is used to find the highest value in a column in SQL.


15.
What is the purpose of the SQL JOIN clause ?
To filter records based on a specified condition
To combine rows from two or more tables
To sort the result set in ascending or descending order
To perform mathematical calculations on numeric columns

The JOIN clause is used to combine rows from two or more tables based on a related column in SQL.


16.
What is the purpose of the SQL GROUP_CONCAT function ?
To perform mathematical calculations on numeric columns
To concatenate values from multiple rows into a single string
To filter records based on a specified condition
To combine rows from two or more tables

The GROUP_CONCAT function is used to concatenate values from multiple rows into a single string in SQL.


17.
Which SQL statement is used to delete records from a table ?
INSERT
UPDATE
SELECT
DELETE

The DELETE statement is used to delete records from a table in SQL.


18.
What is the purpose of the SQL ROW_NUMBER() function ?
To filter records based on a specified condition
To perform mathematical calculations on numeric columns
To assign a unique row number to each row in the result set
To combine rows from two or more tables

The ROW_NUMBER() function is used to assign a unique row number to each row in the result set in SQL.


19.
Which SQL keyword is used to retrieve distinct values from a column ?
DISTINCT
UNIQUE
ALL
HAVING

The DISTINCT keyword is used to retrieve distinct values from a column in SQL.


20.
What is the purpose of the SQL TRUNCATE TABLE statement ?
To filter records based on a specified condition
To combine rows from two or more tables
To delete all records from a table
To perform mathematical calculations on numeric columns

The TRUNCATE TABLE statement is used to delete all records from a table in SQL.


21.
What is the purpose of the SQL RANK() function ?
To filter records based on a specified condition
To perform mathematical calculations on numeric columns
To assign a rank to each row in the result set
To combine rows from two or more tables

The RANK() function is used to assign a rank to each row in the result set in SQL.


22.
Which SQL statement is used to create a new table ?
INSERT
UPDATE
SELECT
CREATE TABLE

The CREATE TABLE statement is used to create a new table in SQL.


23.
What is the purpose of the SQL IN operator ?
To filter records based on a specified condition
To perform mathematical calculations on numeric columns
To check if a value exists in a specified set of values
To combine rows from two or more tables

The IN operator is used to check if a value exists in a specified set of values in SQL.


24.
Which SQL function is used to calculate the average value of a column ?
SUM
AVG
COUNT
MAX

The AVG function is used to calculate the average value of a column in SQL.


25.
What is the purpose of the SQL COALESCE function ?
To filter records based on a specified condition
To perform mathematical calculations on numeric columns
To concatenate values from multiple rows into a single string
To return the first non-null expression in a list

The COALESCE function is used to return the first non-null expression in a list in SQL.


26.
Which SQL statement is used to add a new column to an existing table ?
INSERT
UPDATE
SELECT
ALTER TABLE

The ALTER TABLE statement is used to add a new column to an existing table in SQL.


27.
What is the purpose of the SQL EXISTS operator ?
To filter records based on a specified condition
To perform mathematical calculations on numeric columns
To check if a subquery returns any rows
To combine rows from two or more tables

The EXISTS operator is used to check if a subquery returns any rows in SQL.


28.
Which SQL function is used to find the maximum value in a column ?
SUM
AVG
COUNT
MAX

The MAX function is used to find the maximum value in a column in SQL.


29.
What is the purpose of the SQL OUTER JOIN ?
To filter records based on a specified condition
To combine rows from two or more tables
To sort the result set in ascending or descending order
To perform mathematical calculations on numeric columns

The OUTER JOIN is used to combine rows from two or more tables, including unmatched rows from one or both tables, in SQL.


30.
Which SQL statement is used to rename a table ?
INSERT
UPDATE
SELECT
RENAME TABLE

The RENAME TABLE statement is used to rename a table in SQL.

img

"Embrace curiosity, unlock knowledge"

Copyright © 2023 - Some rights reserved

Made with

in INDIA