LeetCode 1501: Countries You Can Safely Invest In [SQL]

preview_player
Показать описание
Solution and walkthrough of leetcode database problem 1501: Countries You Can Safely Invest In. I'm using MySQL but this solution should work in any SQL dialect such as PostgreSQL SQL Server, etc.

Playlists:

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

Beautiful solution. Thank you so much!

dtmehto
Автор

Very concise answer and wonderful explanation.

Ambu_Singh
Автор

My solution:
select b.name from( select * from calls c join person p on c.caller_id=p.id
Union all
select * from calls c join person p on c.callee_id=p.id) a left join country b on left(a.phone_number, 3)=b.country_code group by b.name having sum(duration)>(select sum(duration) from calls);

shubham
Автор

sir
can you make videos of SQL questions from interview query platform.
It will great help for me.

sauravpandey
Автор

Hi Frederid, is it a must to put single quotation mark at 1st line for 'country'? Thanks.

daniellesong
Автор

Can i ask where do you find the SQL problems on leetcode?

berkouklahcene
Автор

My friend, is this join an inner join? is an inner join a cross join? thank you !

joezhou