[SQL] programmers 특정 형질을 가지는 대장균 찾기

도리·2025년 4월 22일

  • 오답!!!
    # 2번 형질 x, 13번 형질 o 
select count(*) as count
from ecoli_data
where ((genotype & 1 = True) or (genotype & 4 = True)) and (genotype & 2 = False)

비트연산자는 0,1를 반환하는 것이 아니다.
5 & 4 의 결과는 4임.

비트연산자

and (&) - 두개다 1이면 1
or (|) - 하나라도 1이면 1
xor (^) - 두개다 다르면 1

  • 정답!!!
# 2번 형질 x, 13번 형질 o 
select count(*) as count
from ecoli_data
where ((genotype & 1 >= 1 ) or (genotype & 4 >= 4)) and (genotype & 2 != 2)
profile
인공지능응용학과 졸업예정..

0개의 댓글