Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 78c6e84

Browse files
committed
Adding Solution for 2324 and 2346
1 parent 54c7df5 commit 78c6e84

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
WITH grouped_sales AS (
2+
SELECT product_id,user_id,SUM(quantity) AS quantity
3+
FROM sales_2324
4+
GROUP BY product_id,user_id
5+
),
6+
ranked_sales AS (
7+
SELECT s.product_id,s.user_id,s.quantity*p.price AS spent,
8+
RANK() OVER (PARTITION BY s.user_id ORDER BY s.quantity*p.price DESC) AS rnk
9+
FROM grouped_sales s
10+
INNER JOIN product_2324 p ON s.product_id = p.product_id
11+
)
12+
SELECT user_id,product_id
13+
FROM ranked_sales
14+
WHERE rnk = 1;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT student_id,department_id,
2+
ROUND((RANK() OVER (PARTITION BY department_id ORDER BY mark DESC)-1)*100/
3+
(COUNT(student_id) OVER (PARTITION BY department_id)-1),2) AS percentage
4+
FROM students_2346;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /