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 a6fda29

Browse files
committed
Adding Solutions
1 parent a4065c9 commit a6fda29

File tree

52 files changed

+40
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+40
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
WITH posts AS (
2+
SELECT *
3+
FROM submissions_1241
4+
WHERE parent_id IS NULL
5+
),
6+
cmnts AS (
7+
SELECT *
8+
FROM submissions_1241
9+
WHERE parent_id IS NOT NULL
10+
),
11+
cte AS (
12+
SELECT DISTINCT p.sub_id AS post_id,c.sub_id AS cmnt_id
13+
FROM posts p
14+
LEFT JOIN cmnts c
15+
ON p.sub_id = c.parent_id
16+
)
17+
SELECT post_id,COUNT(cmnt_id)
18+
FROM cte
19+
GROUP BY post_id
20+
ORDER BY post_id;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT u.product_id,ROUND(SUM(u.units*p.price)::NUMERIC/SUM(u.units),2)
2+
FROM unit_sold_1251 u
3+
INNER JOIN prices_1251 p
4+
ON u.purchase_date BETWEEN p.start_date AND p.end_date AND
5+
u.product_id = p.product_id
6+
GROUP BY u.product_id;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
WITH exams AS (
2+
SELECT student_id,subject_name,COUNT(1) AS attended_exams
3+
FROM examinations_1280
4+
GROUP BY student_id,subject_name
5+
),
6+
combinations AS (
7+
SELECT st.*,sb.subject_name
8+
FROM students_1280 st
9+
CROSS JOIN subjects_1280 sb
10+
)
11+
SELECT c.student_id,c.student_name,c.subject_name,COALESCE(e.attended_exams,0)
12+
FROM combinations c
13+
LEFT JOIN exams e ON e.student_id = c.student_id AND e.subject_name = c.subject_name
14+
ORDER BY c.student_id,c.subject_name;

‎easy/1294. Weather Type in Each Country (Easy).sql

Whitespace-only changes.

‎easy/1303. Find the Team Size (Easy).sql

Whitespace-only changes.

‎easy/1322. Ads Performance (Easy).sql

Whitespace-only changes.

‎easy/1327. List the Products Ordered in a Period (Easy).sql

Whitespace-only changes.

‎easy/1350. Students With Invalid Departments (Easy).sql

Whitespace-only changes.

‎easy/1378. Replace Employee ID With The Unique Identifier (Easy).sql

Whitespace-only changes.

‎easy/1407. Top Travellers (Easy).sql

Whitespace-only changes.

0 commit comments

Comments
(0)

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