Mid-levelMultiple choiceWrite an SQL query to find the second-highest salary.ASELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 2;BSELECT MAX(salary) AS SecondHighestSalary FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);CSELECT salary FROM employees WHERE salary = (SELECT MAX(salary) FROM employees);DSELECT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 1;Check answer
Mid-levelMultiple choiceWhat is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN?AINNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN all perform the same operation.BINNER JOIN combines rows with matching values; LEFT JOIN includes all rows from the left table; RIGHT JOIN includes all rows from the right table; FULL JOIN includes all rows with matches in either table.CINNER JOIN includes no rows; LEFT JOIN includes all rows from the right table; RIGHT JOIN includes all rows from the left table; FULL JOIN includes matching rows only.DINNER JOIN includes all rows from both tables; LEFT JOIN includes matching rows only; RIGHT JOIN includes non-matching rows only; FULL JOIN includes no rows.Check answer
Mid-levelMultiple choiceWhich SQL method would you use to find the second-highest salary from an employee table using a subquery?ASELECT MAX(salary) FROM employeeBSELECT salary FROM employee WHERE salary = (SELECT MAX(salary) FROM employee)CSELECT salary FROM employee ORDER BY salary DESC LIMIT 2DSELECT MAX(salary) AS SecondHighest FROM employee WHERE salary < (SELECT MAX(salary) FROM employee)Check answer
JuniorMultiple choiceWhy does the RANK() function in SQL skip sequence numbers?ABecause it assigns the same rank to all unique values.BBecause it assigns ranks in a continuous sequence without skipping.CBecause it ignores all NULL values in the dataset.DBecause it assigns the same rank to all duplicate values and skips to the next rank.Check answer
JuniorMultiple choiceWhat are joins in SQL and what are its types?AA JOIN clause is used to combine rows from two or more tables, based on a related column between them. Types include: inner join, left join, right join, and full join.BA JOIN clause is used to create tables. Types include: inner join, left join, right join, and full join.CA JOIN clause is used to update rows in a single table. Types include: self join, cross join, and natural join.DA JOIN clause is used to delete rows from two or more tables. Types include: inner join, left join, right join, and cross join.Check answer