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
2 changes: 2 additions & 0 deletions Combine_Two_Tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT p.firstName, p.lastName, a.city, a.state FROM Person p
LEFT JOIN Address a ON p.personId = a.personId;
2 changes: 2 additions & 0 deletions Game_play_analysis_III.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT player_id, event_date, SUM(games_played) OVER(partition by player_id ORDER BY event_date)
AS 'games_played_so_far' FROM Activity;
8 changes: 8 additions & 0 deletions customers_with_strictly_increasing.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
WITH CTE AS (
SELECT customer_id, substr(order_date,1,4) as o_date, sum(price) as total FROM Orders
Group by substr(order_date,1,4), customer_id
)

SELECT a.customer_id FROM CTE a LEFT JOIN CTE b ON a.customer_id = b.customer_id and a.o_date + 1 = b.o_date and a.total < b.total
Group by a.customer_id
Having count(distinct b.o_date) = max(a.o_date) - min(a.o_date)
2 changes: 2 additions & 0 deletions gmae_play_analysis_ii.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT DISTINCT player_id, FIRST_VALUE(device_id) OVER(PARTITION BY player_id
ORDER BY event_date) AS device_id FROM Activity;
2 changes: 2 additions & 0 deletions shortest_distance_in_a_plane.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT ROUND(SQRT(MIN(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;