Home

부모의 형질을 모두 가지는 대장균 찾기

Link

Tables

Question

부모의 형질을 모두 보유한 대장균의 ID(ID), 대장균의 형질(GENOTYPE), 부모 대장균의 형질(PARENT_GENOTYPE)을 출력하는 SQL 문을 작성해주세요. 이때 결과는 ID에 대해 오름차순 정렬해주세요.

DataFlow

selft join
비트 연산

Answer

select c.id, c.genotype, p.genotype as parent_genotype from ecoli_data c join ecoli_data p on c.parent_id = p.id and (p.genotype & c.genotype) = p.genotype where c.parent_id is not null order by c.id asc;
SQL
복사

Intention

부모의 형질을 모두 보유한 이라는 문제의 의도를 이해
비트 연산이 가능한지