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
10 changes: 10 additions & 0 deletions combinetwotables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SELECT
Person.firstName,
Person.lastName,
Address.city,
Address.state
FROM Person
LEFT JOIN Address
USING (personId);


23 changes: 23 additions & 0 deletions customerwithincrease.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
select
customer_id
from
(
select
customer_id,
year(order_date),
sum(price) as total,
year(order_date) - rank() over(
partition by customer_id
order by
sum(price)
) as rk
from
Orders
group by
customer_id,
year(order_date)
) t
group by
customer_id
having
count(distinct rk) = 1;
13 changes: 13 additions & 0 deletions gameplayanalysis2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Write your MySQL query statement below
SELECT
player_id,
device_id
FROM Activity
WHERE
(player_id, event_date) IN (
SELECT
player_id,
MIN(event_date) AS event_date
FROM Activity
GROUP BY 1
);
8 changes: 8 additions & 0 deletions gameplayanalysis3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
player_id,
event_date,
SUM(games_played) OVER (
PARTITION BY player_id
ORDER BY event_date
) AS games_played_so_far
FROM Activity;
18 changes: 18 additions & 0 deletions shortestdistance.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SELECT
ROUND(
SQRT(
MIN(POW(a.x-b.x,2) + POW(a.y-b.y,2))
)
,2
) shortest
FROM point_2d a
CROSS JOIN point_2d b
WHERE NOT (a.x = b.x AND a.y = b.y)


SELECT ROUND(SQRT(POW(p1.x - p2.x, 2) + POW(p1.y - p2.y, 2)), 2) AS shortest
FROM
Point2D AS p1
JOIN Point2D AS p2 ON p1.x != p2.x OR p1.y != p2.y
ORDER BY 1
LIMIT 1;