jinseon's log

[엘카데미] 엘카데미 챌린지_SQL 레벨 테스트_20일차 본문

ML & DL/엘카데미

[엘카데미] 엘카데미 챌린지_SQL 레벨 테스트_20일차

J_SEON 2023. 8. 5. 12:33

 

[두번째 이야기]

[문제 1] 출력 순서 바꾸기

select
    name,
    caution
from
    student
order by
    caution desc;

 

[문제 2] 기숙사 퇴사 처리하기

- delete from 등 명령어가 생각나지 않아서 할 때마다 헷갈렸다

- 아직도 잘 외워지지는 않는 것 같다

select
    name,
    caution
from
    student
where
    name = "Dodo";

delete from
    student
where
    name = "Dodo";

select
    *
from
    student;

 

[문제 3] 파이데이

- like 사용법도 다시 공부했다

- 해당 문제도 이해가 잘 안돼서 오래걸렸다 😂

select
    name,
    grade
from
    student
where
    name like "%pi%";

 

[문제 4] 방 배정상태 확인

select
    room,
    count(*)
from
    student
group by
    room;

 

[문제 5] 빈방 찾아내기

- group by 다음에 where이 아닌 having을 사용해야 하는 것이 생각나지 않아서 문제 풀이에 시간을 많이 썼다

- 시간이 오래 걸린 만큼 기억에도 오래 남을 것 같다

select
    room
from
    student
group by
    room
having
    count(room) = 1;

 

Comments