Solve problems using SQL
Hey hi, today I’ve brought few interesting SQL problems to you….
- You are being given with a theatere’s data which contains all the movies screened there on their release date, release date of movie and revenue collected in Crores.
So here we need to find the movie name and it’s release date when revenue of Phoenix theatre reached 11000 Cr.
To solve it we will use cumulative sum and then we will filter on this cumulative sum.
with cumulative_collection as ( select *, sum(Collection_amount) over(order by Release_date asc) as running_amount
from Phoneix_theatre)
select Movie_Name, Release_date, running_amount
from cumulative_collection
where running_amount=11000;
2. You are being given two tables: table A and table B
and you are being asked to give new table along with total no. of records in table after joining both A and B on a and b using following joins:
i) Left Join
ii) Right Join
iii) Inner join
iv) Full outer join
v) Cross join
You can watch this embedded video for better understanding:
Get Taru Sahu’s stories in your inbox
Join Medium for free to get updates from this writer.
Left join:
Right join:
Inner join:
Full outer join:
Cross join:
Total 30 records will be returned as a result of cartesian product of column a and column b from table A and table B respectively.
If you find it insightful share your thoughts in comment box!
Thanks!








