[SQL] 이름에 el이 들어가는 동물 찾기(Oracle) 난이도 Level 2 문제의 조건에 "대소문자를 구별하지 않는다" 라고 친절하게 안내가 나와있으니 헷갈리면 내 탓. lower(name)을 해줘야 맞출 수 있다. like문을 활용할 수 있으면 풀 수 있는 문제. SELECT animal_id, name from animal_ins where lower(name) like '%el%' and animal_type='Dog' order by name; 코딩테스트/프로그래머스 2022.05.02
[70129] 이진변환 반복하기 입력받은 수에 대하여 0을 모두 제거하고 제거한 수를 이진수로 변환, 그 이진수가 1이 될 때 까지 반복한 뒤 제거한 0의 개수와 이진수로 변환한 총 횟수를 출력하면 된다. 나는 무식하게 recursive function으로 구현했는데, 어떤 분의 좋은 코드에서 멋진 코드를 발견해서 여기에 올린다. (프로필 정보가 없어서 어떻게 공유해야할 지 모르겠다.) s = Convert.ToString(101101, 2); System의 Convert. VS에서 친절하게 아래와 같이 설명해준다. Convert.ToString(int value, int toBase); Converts the value of a 32-bit signed integer to its equivalent string representati.. 코딩테스트/프로그래머스 2022.04.18
[SQL] 우유와 요거트가 담긴 장바구니(Oracle) 난이도 : Level 4 풀릴듯 말듯 했다... 쉬운듯 아닌듯.. subquery를 활용해서 풀었는데.. 뭔가 답만 나오면 다였던 수준. 더 clean하게 정리할 수 없을까? select cart_id from ( -- 여기에서 cart_id와 name으로 묶어서 count를 센다. select cart_id, name, count(*) as canmcount from cart_products where name in ('Milk', 'Yogurt') group by cart_id, name order by cart_id ) -- 여기에서 1차적으로 한 품목을 두개이상 담는 사람이 걸러진다. where canmcount < 2 -- 그 후 cart_id로 묶어주면 한 품목만 담았던 사람은 count시 1.. 코딩테스트/프로그래머스 2022.04.15
[SQL] 헤비 유저가 소유한 장소(Oracle) 난이도 : Level3 여러방법으로 풀 수 있겠지만, 나의 경우에는 subquery로 풀었다. order by 안하면 틀렸다고 하더라(;;;) SELECT id, name, host_id from places where host_id in ( select host_id as count from places group by host_id having count(*) > 1 ) order by id; 코딩테스트/프로그래머스 2022.04.15
[SQL] 없어진 기록 찾기(Oracle) 난이도 : Level 3 Outer join을 이용해서 Animal_ins가 null인 값을 찾아주는 문제이다. Outer join 개념을 알고있다면 어렵지 않게 풀 수 있는 것 같다. select outs.animal_id, outs.name from animal_ins ins full outer join animal_outs outs on ins.animal_id = outs.animal_id where ins.animal_id is null order by outs.animal_id; 코딩테스트/프로그래머스 2022.04.15