LeetCode Medium 1990 'Number of Experiments' Twitter Interview SQL Question Detailed Explanation

preview_player
Показать описание

In this video I solve and explain a medium difficulty leetcode SQL question using MySQL query. This question has been asked in Apple, Facebook, Amazon, Google, Adobe, Microsoft, Adobe interviews or what we popularly call FAANG interviews.
I explain the related concept as well. This question includes points to keep in mind to develop SQL queries.

LeetCode is the best platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.

If you found this helpful, Like and Subscribe to the channel for more content.

#LeetCodeSQL #FAANG #SQLinterviewQuestions
Рекомендации по теме
Комментарии
Автор

Hi, useful videos.. thank you.. one question- we are hard coding the values and union them to list the all platform or experiment names; here the values are 3, but if we have more values, we can’t hardcode all the values and the code will be cumbersome.. could you please tell the alternative way

praneethreddy
Автор

select distinct a.platform, distinct b.experiment_name from experiment 1 cross join experiment b will work or not

ujjwalvarshney
Автор

Bro, instead of using another cte you could've done this:

WITH cte AS
(SELECT *
FROM (SELECT "Android" AS platform UNION SELECT "IOS" UNION SELECT "Web") t1
CROSS JOIN
(SELECT "Reading" AS experiment_name UNION SELECT "Sports" UNION SELECT "Programming") t2)

SELECT c.*, IFNULL(COUNT(e.experiment_id), 0) AS num_experiments
FROM cte c
LEFT JOIN Experiments e
ON c.platform = e.platform AND c.experiment_name = e.experiment_name
GROUP BY c.platform, c.experiment_name

sachindewangan