Question : Which SQL statement is used to retrieve data from a database table?
Solution :
Correct Answer : SELECT
Description -
Question : Which symbol is used to select all columns from a table?
Solution :
Correct Answer : *
Description -
Question : Which keyword removes duplicate values from the result?
Solution :
Correct Answer : DISTINCT
Description -
Question : What is the output of the following query?
SELECT COUNT(*) FROM students;
Solution :
Correct Answer : Counts rows
Description -
Question : Which statement returns the first 5 rows in SQL Server?
Solution :
Correct Answer : SELECT TOP 5 * FROM table;
Description -
Question : Which clause is commonly used in MySQL to fetch limited rows?
Solution :
Correct Answer : LIMIT
Description -
Question : Which query selects unique department names?
Solution :
Correct Answer : Both B and C
Description -
Question : Which function is used to calculate the total sum of values?
Solution :
Correct Answer : SUM()
Description -
Question : What does COUNT(column_name) do?
Solution :
Correct Answer : Counts non-NULL values
Description -
Question : Which query retrieves random rows in MySQL?
Solution :
Correct Answer : SELECT * FROM emp ORDER BY RAND();
Description -
Question : Which operator checks multiple values in a condition?
Solution :
Correct Answer : IN
Description -
Question : What is the purpose of DISTINCT?
Solution :
Correct Answer : Display unique values
Description -
Question : Which query finds total marks?
Solution :
Correct Answer : SELECT SUM(marks) FROM exam;
Description -
Question : Which SQL clause is used with dates?
Solution :
Correct Answer : WHERE
Description -
Question : Which query returns records where salary is NULL?
Solution :
Correct Answer : SELECT * FROM emp WHERE salary IS NULL;
Description -
Question : Which keyword is used to check NOT NULL values?
Solution :
Correct Answer : IS NOT NULL
Description -
Question : Which query selects multiple columns?
Solution :
Correct Answer : SELECT name, salary FROM emp;
Description -
Question : What is the output of: SELECT COUNT(DISTINCT city) FROM customers;
Solution :
Correct Answer : Counts unique cities
Description -
Question : Which statement is correct for selecting last records?
Solution :
Correct Answer : ORDER BY with DESC is commonly used
Description -
Question : Which clause sorts query results?
Solution :
Correct Answer : ORDER BY
Description -
Question : Which query selects employees with IDs 1, 3, and 5?
Solution :
Correct Answer : SELECT * FROM emp WHERE id IN (1,3,5);
Description -
Question : Which function ignores NULL values automatically?
Solution :
Correct Answer : All of the above
Description -
Question : Which query returns 10 random records in MySQL?
Solution :
Correct Answer : SELECT * FROM emp ORDER BY RAND() LIMIT 10;
Description -
Question : Which SQL keyword is used to rename a column in output?
Solution :
Correct Answer : AS
Description -
Question : Which query correctly selects records between two dates?
Solution : SELECT * FROM orders
Correct Answer :
WHERE order_date BETWEEN '2026-01-01' AND '2026-12-31';
Description -
Question : What does SELECT DISTINCT salary FROM emp; do?
Solution :
Correct Answer : Displays only unique salary values
Description -
Question : Which statement is true about NULL?
Solution :
Correct Answer : NULL means unknown/missing value
Description -
Question : Which query finds total number of employees?
Solution :
Correct Answer : SELECT COUNT(*) FROM emp;
Description -
Question : Which SQL query selects students born after 2000?
Solution : SELECT * FROM students
Correct Answer :
WHERE birth_date > '2000-12-31';
Description -
Question : Which statement retrieves only one random row in PostgreSQL?
Solution :
Correct Answer : SELECT * FROM emp RANDOM 1;
Description -