Here are 7 of the questions:
1. What SQL statements would you use to get all unique values from a column?
Answer: SELECT DISTINCT(column_name) FROM table_name;
2. How would you select the top 5 items of a list in SQL?
Answer: SELECT column_name_1, column_name_2 FROM table_name ORDER BY column_name_1 DESC LIMIT 5;
3. Can you explain the difference between a left join and an inner join?
Answer: A left join returns all the values from the left table and matching values from the right table, while an inner join only returns matching values from both tables.
4. How can you find the second-highest salary from an employee table in SQL?
Answer: SELECT MAX(salary) FROM employee WHERE salary < (SELECT MAX(salary) FROM employee); 5. Explain the difference between the COUNT() and SUM() functions in SQL? Answer: COUNT() returns the number of rows in a table, while SUM() returns the sum of values in a specific column. 6. How can you find duplicate rows in a table? Answer: SELECT column_name(s) FROM table_name GROUP BY column_name(s) HAVING COUNT(*) > 1;
7. How would you order a table by multiple columns in descending order in SQL?
Answer: SELECT column_name_1, column_name_2 FROM table_name ORDER BY column_name_1 DESC, column_name_2 DESC;