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 0e32c58

Browse files
committed
고다혜: [SQL] 멸종위기의 대장균 찾기_250226
1 parent 8c83e33 commit 0e32c58

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
WITH recursive CTE AS (
2+
SELECT id, parent_id, 1 as GENERATION
3+
FROM ECOLI_DATA
4+
WHERE PARENT_ID IS NULL
5+
6+
UNION ALL
7+
8+
SELECT b.id, b.parent_id, a.generation + 1
9+
FROM CTE a
10+
JOIN ECOLI_DATA b ON a.id = b.parent_id
11+
)
12+
13+
SELECT COUNT(a.ID) as COUNT, a.GENERATION
14+
FROM CTE a
15+
WHERE ID NOT IN (
16+
SELECT DISTINCT PARENT_ID
17+
FROM CTE
18+
WHERE PARENT_ID IS NOT NULL
19+
)
20+
GROUP BY a.GENERATION
21+
ORDER BY a.GENERATION

0 commit comments

Comments
(0)

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