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
1 change: 1 addition & 0 deletions Combine Two Tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT p.firstName, p.lastName, a.city, a.state FROM Person p LEFT JOIN Address a ON p.personID = a.personID
8 changes: 8 additions & 0 deletions Customers with Strictly Increasing Purchases.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
WITH CTE AS(
SELECT customer_id , YEAR(order_date) as 'year', SUM(price) as 'price' from orders GROUP BY year , customer_id
order by customer_id , year
)

SELECT 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;
1 change: 1 addition & 0 deletions Game Play Analysis II.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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)
1 change: 1 addition & 0 deletions Game Play Analysis III.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT player_id, event_date, SUM(games_played) OVER (PARTITION BY player_id ORDER BY event_date) AS 'games_played_so_far' FROM Activity
1 change: 1 addition & 0 deletions Shortest Distance in a Plane.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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