[패스트캠퍼스] SQL 강의 5주차

Jongwook Yoon·2022년 9월 27일
0

강의수강

목록 보기
5/5

[내일배움카드취업]

HackerRank 문제 풀이
1. Blunder
select ceil(avg(salary) - avg(replace(salary,'0','')))
from EMPLOYEES
2. Top Earners
select salarymonths, count()
from Employee
where salarymonths = (select max(salarymonths)
from Employee)
group by 1
3.Weather Observation Station 15
select round(LONG_W,4)
from station
where LAT_N = (select max(LAT_N)
from Station
where LAT_N < 137.2345)
4. Weather Observation Station 19
select round(sqrt(power(min(LAT_N)-max(LAT_N),2) + power(min(LONG_W)-max(LONG_W),2)),4)
from station

Triangle

case 사용 select case when(a=b and b=c and a=c) then 'equilateral'
when (a=b or b=c or c=a) then 'Isosceles'
when a+b <= c or a+c <=b or b+c <= a then 'Not A Triangle'
else 'scalene'
end
from triangles
순차적으로 조건을 체크함

PADS
select name, occupation ->concat 사용
'#concat(name,'(',upper(substr(occupation,1,1))')') ->substring (몇번째 인덱스부터 몇개까지 여긴 1부터 시작함)
from OCCUPATIONS

Join은 좀 어렵다...

0개의 댓글