From 72811834ae6850a449ccdbe97cecca3649ae9e61 Mon Sep 17 00:00:00 2001 From: Shree1101 <71892807+Shree1101@users.noreply.github.com> Date: Sun, 19 Jan 2025 19:11:56 -0500 Subject: [PATCH] Create SQL2 --- SQL2 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 SQL2 diff --git a/SQL2 b/SQL2 new file mode 100644 index 0000000..4561b0e --- /dev/null +++ b/SQL2 @@ -0,0 +1,25 @@ +Q1. Rank Scores +# Write your MySQL query statement b +SELECT Score, Dense_Rank() over + (order by score Desc) AS 'RANK' from Scores; + +Q2. Exchange Seats +# Write your MySQL query statement below +SELECT + CASE + WHEN MOD(id, 2) != 0 AND id != cnt THEN id + 1 + WHEN MOD(id, 2) != 0 AND id = cnt THEN id + ELSE id - 1 + END AS id, + student FROM Seat, (SELECT COUNT(*) AS cnt FROM Seat) AS seat_counts ORDER BY id; + +Q.3 Tree Node +# Write your MySQL query statement below +SELECT id, ( + CASE + when p_id IS NULL then 'Root' + when id NOT IN(Select Distinct p_id from Tree WHERE + p_id is NOT NULL) then 'Leaf' + ELSE 'Inner' + END +) AS 'type' from Tree;