본문 바로가기
Algorithm & SQL/SQL

[solvesql] SQL 문제 풀이

by YoonJong 2023. 1. 29.
728x90

1. 모든 데이터 조회하기

https://solvesql.com/problems/select-all/

select * 
from points;

 

2. 일부 데이터 조회하기

https://solvesql.com/problems/select-where/

select * 
from points 
where quartet = 'I';

 

3. 데이터 정렬하기

https://solvesql.com/problems/order-by/

select * 
from points 
where quartet = 'I' 
order by y;

 

4. 데이터 그룹으로 묶기

https://solvesql.com/problems/group-by/

select 
quartet,
round(avg(x),2) as x_mean,
round(variance(x),2) as x_var,
round(avg(y),2) as y_mean,
round(variance(y),2) as y_var
from points
group by quartet;

 

5. 두 테이블 결합하기

https://solvesql.com/problems/join/

select
distinct r.athlete_id
from events e
join records r
on e.id = r.event_id
where e.sport = 'Golf';
728x90

'Algorithm & SQL > SQL' 카테고리의 다른 글

[solvesql] SQL 문제 풀이 (3)  (0) 2023.01.31
[solvesql] SQL 문제 풀이 (2)  (0) 2023.01.30
SQL 예제  (0) 2022.06.28
Average Population of Each Continent - BASIC JOIN  (0) 2022.06.09
African Cities - BASIC JOIN  (0) 2022.06.09

댓글