Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Problem1_GamePlay2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Write your MySQL query statement below
select a.player_id, a.device_id
from activity a
where a.event_date in (select min(b.event_date) from activity b where a.player_id=b.player_id)
5 changes: 5 additions & 0 deletions Problem2_GamePlay3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Write your MySQL query statement below
select
player_id,event_date,
sum(games_played) over(partition by player_id order by event_Date) as games_played_so_far
from activity;
6 changes: 6 additions & 0 deletions Problem3_shortestDist.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Write your MySQL query statement below
select
round(min(sqrt(pow(p2.x-p1.x,2)+pow(p2.y-p1.y,2))),2) as shortest
from point2d p1
inner join point2d p2
on p1.x!=p2.x or p1.y!=p2.y
4 changes: 4 additions & 0 deletions Problem4_Combine2Tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Write your MySQL query statement below
select p.firstname,p.lastname,a.city,a.state
from Person P
left join address a on p.personid=a.personid
14 changes: 14 additions & 0 deletions Problem5_CustomersWithIncreasingPurchase.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Write your MySQL query statement below
with cte as (
select distinct customer_id,year(order_date) as year,
sum(price) over(partition by customer_id,year(order_date)) as price
from Orders order by customer_id,year)

select
distinct c1.customer_id
from cte c1
left join cte c2 on c1.customer_id=c2.customer_id
and c1.year +1= c2.year
and c1.price < c2.price
group by c1.customer_id
having count(*)-count(c2.customer_id)=1;