본문 바로가기

Data40

[프로그래머스] FrontEnd 개발자 찾기 문제DEVELOPERS 테이블에서 Front End 스킬을 가진 개발자의 정보를 조회하려 합니다. 조건에 맞는 개발자의 ID, 이메일, 이름, 성을 조회하는 SQL 문을 작성해 주세요. 결과는 ID를 기준으로 오름차순 정렬해 주세요.  풀이비트 연산자를 활용해 해결 가능하다.SELECT ID, EMAIL, FIRST_NAME, LAST_NAMEFROM DEVELOPERSWHERE SKILL_CODE & (SELECT SUM(CODE) FROM SKILLCODES WHERE CATEGORY = "Front End")-- skillcodes 테이블에서 front end 카테고리에 해당하는 code의 합계와 developers 테이블의 skill_code 값을 &비트연산자로 계산ORDER BY ID 결과값 계.. 2025. 1. 2.
[solvesql] 다음날도 서울숲의 미세먼지 농도는 나쁨 😢 문제 서울숲 일별 평균 대기오염도 데이터셋은 2022년 서울숲 대기오염도 측정소에서 매일 기록한 대기오염 정보를 담고 있습니다. measurements 테이블의 pm10 컬럼에는 다양한 대기오염도 측정 기준 중에서도 미세먼지(PM10) 농도가 기록되어 있습니다. 이 데이터를 이용하여 당일의 미세먼지 농도보다 바로 다음날의 미세먼지 농도가 더 안좋은 날을 찾아주세요. 결과는 아래 컬럼들을 포함해야 합니다. * 윈도우 함수 사용하기 * lead는 다음값, lag는 이전값을 가져오는 함수 풀이 with t1 as (select measured_at as today , lead(measured_at) over (order by measured_at) as next_day , pm10 , lead(pm10) ov.. 2024. 2. 24.
[Leetcode] 1045. Customers Who Bought All Products product 테이블에 있는 product key를 모두 구입한 customer 테이블의 customer_id를 구하는 문제 having절과 count 함수를 함께 사용해서 조건절을 만들었다. select distinct customer_id from customer group by customer_id having count(distinct product_key) = (select count(distinct product_key) from product) 2024. 1. 19.
[Leetcode] 175. Combine Two Tables, 178. Rank Scores, 184. Department Highest Salary 175. Combine Two Tables select firstName, lastName, city, state from person p left join address a on p.personId = a.personId 178. Rank Scores select score, (dense_rank() over (order by score desc)) as 'rank' from scores order by score desc 184. Department Highest Salary select d.name as Department, e.name as Employee, salary as Salary from Employee e, Department d where e.departmentId = d.id and.. 2024. 1. 15.
[Leetcode] 1661. Average Time of Process per Machine 풀이 select a1.machine_id, round(avg(a2.timestamp - a1.timestamp), 3) as processing_time from Activity a1 join Activity a2 on a1.process_id = a2.process_id and a1.machine_id = a2.machine_id where a1.activity_type = 'start' and a2.activity_type = 'end' group by a1.machine_id order by a1.machine_id 2024. 1. 9.
[Leetcode] 602. Friend Requests II: Who Has the Most Friends * union all 활용해서 두 테이블을 합친 with절 테이블을 생성 with tbn as ( select requester_id as id from RequestAccepted union all select accepter_id as id from RequestAccepted ) select id, count(*) as num from tbn group by id order by num desc limit 1 2024. 1. 9.