SQL
The SQL questions and answers in this lesson will help you understand the types of SQL questions you can expect in data science interviews.
We'll cover the following...
What is wrong with the query below?
This query will get the average order amount by UserId for the customers with at least 1 order. So, we need to use the GROUP BY function to group the customers by UserId. Therefore, the correct query would be:
Consider the below table. Write a query that retrieves all employees not recruited by any recruiter.
Employee
Id | Name | RecruitedBy |
1 | Ross Taylor | NULL |
2 | Andy Smith | 1 |
3 | Scarlett Berry | NULL |
4 | Evelyn Depp | 3 |
5 | John Lee | 3 |
6 | James Dean | NULL |
The query that retrieves all employees that are not recruited by any recruiter is:
What is the difference between DELETE and TRUNCATE?
The DELETE command can be used to remove rows from the table and uses the WHERE clause. We can also perform COMMIT and ROLLBACK after a DELETE command. On the other hand, the TRUNCATE command removes all rows from the table, ...