πŸ“Š MySQL
Q. Which statement will return the second highest salary?
Code:
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
  • (A) Returns average salary
  • (B) Returns the second highest salary
  • (C) Returns lowest salary
  • (D) Returns all salaries except highest
πŸ’¬ Discuss
βœ… Correct Answer: (B) Returns the second highest salary

Explanation: The subquery gets the highest salary; the outer query finds the max below that.

πŸ“Š MySQL
Q. Which keyword is used to avoid duplicate entries in SELECT?
  • (A) UNIQUE
  • (B) EXCEPT
  • (C) DISTINCT
  • (D) NODUP
πŸ’¬ Discuss
βœ… Correct Answer: (C) DISTINCT

Explanation: `DISTINCT` ensures the returned values are unique.

πŸ“Š MySQL
Q. What does this query do?
Code:
SELECT COUNT(DISTINCT country) FROM customers;
  • (A) Counts total countries
  • (B) Counts all customers
  • (C) Counts unique countries
  • (D) Counts duplicate countries
πŸ’¬ Discuss
βœ… Correct Answer: (C) Counts unique countries

Explanation: `COUNT(DISTINCT column)` counts only unique values in the column.

πŸ“Š MySQL
Q. Which function is used to round numbers in MySQL?
  • (A) ROUND()
  • (B) CEIL()
  • (C) FLOOR()
  • (D) TRUNC()
πŸ’¬ Discuss
βœ… Correct Answer: (A) ROUND()

Explanation: `ROUND()` rounds a number to the specified number of decimal places.

πŸ“Š MySQL
Q. Which clause is used to group rows that have the same values?
  • (A) GROUP BY
  • (B) COLLATE
  • (C) SORT BY
  • (D) AGGREGATE BY
πŸ’¬ Discuss
βœ… Correct Answer: (A) GROUP BY

Explanation: `GROUP BY` is used to group rows with the same values for aggregate functions.