Recent Posts
목록2025/08/23 (2)
zimslog
[SQL] 프로그래머스 - 5월 식품들의 총매출 조회하기
처음 정답 코드)-- 생산일자 22.5-- id, name, 총매출-- order by 총매출 desc, id ascSELECT F.PRODUCT_ID, F.PRODUCT_NAME, F.PRICE*O.AMOUNT AS TOTAL_SALESFROM FOOD_PRODUCT FJOIN (SELECT PRODUCT_ID, SUM(AMOUNT) AS AMOUNTFROM FOOD_ORDERWHERE DATE_FORMAT(PRODUCE_DATE,'%Y-%m') = '2022-05'GROUP BY PRODUCT_ID) OON F.PRODUCT_ID = O.PRODUCT_IDORDER BY TOTAL_SALES DESC, PRODUCT_ID ASC
Data Engineering/SQL
2025. 8. 23. 15:37
[SQL] 프로그래머스 - 상품의 구매한 회원 비율 구하기
프로그래머스 - 상품의 구매한 회원 비율 구하기 처음 정답 코드)SELECT YEAR(SALES_DATE) as YEAR, MONTH(SALES_DATE) AS MONTH, COUNT(DISTINCT S.USER_ID) AS PURCHASED_USERS, ROUND( COUNT(DISTINCT S.USER_ID)/J.CNT , 1) AS PURCHASED_RATIOFROM ONLINE_SALE SJOIN (SELECT COUNT(*) AS CNT FROM USER_INFO WHERE YEAR(JOINED) = 2021) JWHERE EXISTS (SELECT 1 FROM USER_INFO ..
Data Engineering/SQL
2025. 8. 23. 15:08