From 017e54e23e4b494f9e00f7a7c0fff356d576efd9 Mon Sep 17 00:00:00 2001 From: itsAbilash <102655634+itsAbilash@users.noreply.github.com> Date: Mon, 27 Jan 2025 11:23:25 -0600 Subject: [PATCH] add all --- Combine_Two_Tables.txt | 1 + Customers_with_Strictly_Increasing_Purchase.txt | 4 ++++ Gameplay_Analysis_II.txt | 1 + Gameplay_Analysis_III.txt | 3 +++ Shortest_Distance_Between_two_Plane.txt | 8 ++++++++ 5 files changed, 17 insertions(+) create mode 100644 Combine_Two_Tables.txt create mode 100644 Customers_with_Strictly_Increasing_Purchase.txt create mode 100644 Gameplay_Analysis_II.txt create mode 100644 Gameplay_Analysis_III.txt create mode 100644 Shortest_Distance_Between_two_Plane.txt diff --git a/Combine_Two_Tables.txt b/Combine_Two_Tables.txt new file mode 100644 index 0000000..118ba94 --- /dev/null +++ b/Combine_Two_Tables.txt @@ -0,0 +1 @@ +SELECT P.firstName, P.LastName, A.City, A.state from Person P left join address A on P.personId = A.personID; \ No newline at end of file diff --git a/Customers_with_Strictly_Increasing_Purchase.txt b/Customers_with_Strictly_Increasing_Purchase.txt new file mode 100644 index 0000000..37eec2a --- /dev/null +++ b/Customers_with_Strictly_Increasing_Purchase.txt @@ -0,0 +1,4 @@ +WITH CTE AS ( + SELECT CUSTOMER_ID,YEAR(ORDER_DATE)AS YEARS ,SUM(PRICE) AS S_PRICE FROM ORDERS GROUP BY CUSTOMER_ID,YEARS ORDER BY CUSTOMER_ID,YEARS +) +SELECT C1.CUSTOMER_ID FROM CTE C1 LEFT JOIN CTE C2 ON C1.CUSTOMER_ID = C2.CUSTOMER_ID AND C1.YEARS + 1 = C2.YEARS AND C1.S_PRICE < C2.S_PRICE GROUP BY C1.CUSTOMER_ID HAVING COUNT(*) - COUNT(C2.CUSTOMER_ID) = 1; \ No newline at end of file diff --git a/Gameplay_Analysis_II.txt b/Gameplay_Analysis_II.txt new file mode 100644 index 0000000..b678e69 --- /dev/null +++ b/Gameplay_Analysis_II.txt @@ -0,0 +1 @@ +select Player_id, device_id from (select distinct player_id,rank() over (partition by player_id order by event_date) as rnk , device_id from activity) a where a.rnk = 1; \ No newline at end of file diff --git a/Gameplay_Analysis_III.txt b/Gameplay_Analysis_III.txt new file mode 100644 index 0000000..c15753c --- /dev/null +++ b/Gameplay_Analysis_III.txt @@ -0,0 +1,3 @@ +SELECT player_id, event_date, +SUM(games_played) OVER (PARTITION BY player_id ORDER BY event_date) AS games_played_so_far +FROM Activity; \ No newline at end of file diff --git a/Shortest_Distance_Between_two_Plane.txt b/Shortest_Distance_Between_two_Plane.txt new file mode 100644 index 0000000..c84c5e6 --- /dev/null +++ b/Shortest_Distance_Between_two_Plane.txt @@ -0,0 +1,8 @@ +SELECT + ROUND(MIN(SQRT(POWER(p1.x - p2.x, 2) + POWER(p1.y - p2.y, 2))), 2) AS shortest +FROM + Point2D p1 +JOIN + Point2D p2 +ON + p1.x != p2.x OR p1.y != p2.y;