[SQL] programmers 대장균들의 자식의 수 구하기

도리·2025년 4월 22일

  • 정답코드
# parent_id 몇개 있는지 count해서 child_count로?
with count_child as (
select parent_id , count(parent_id) as child_count
from ecoli_data
where parent_id is not null
group by parent_id)
select e.id, ifnull(c.child_count,0) as child_count
from ecoli_data e
left outer join count_child c  on e.id = c.parent_id
order by  e.id
profile
인공지능응용학과 졸업예정..

0개의 댓글