일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- Gaimification
- kaggle
- 신경쓰기의 기술
- leetcode
- ProfileReport
- 파이썬
- 프로그래머스
- eda
- 코딩테스트연습
- forecast
- MySQL
- Product Demand
- 딥러닝
- Inventory Optimization
- TensorFlowGPU
- tensorflow
- 피그마인디언
- Labor Management System
- MS SQL Server
- ABC Analysis
- 데이터분석
- 당신의 인생이 왜 힘들지 않아야 한다고 생각하십니까
- oracle
- SKU Consolidation
- ModelCheckPoint
- HackerRank
- 웨어하우스 보관 최적화
- SQL
- pandas profiling
- 코딩테스트
- Today
- Total
목록MySQL (67)
오늘도 배운다

문제 source: LeetCode If the customer's preferred delivery date is the same as the order date, then the order is called immediate; otherwise, it is called scheduled. The first order of a customer is the order with the earliest order date that the customer made. It is guaranteed that a customer has precisely one first order. Write an SQL query to find the percentage of immediate orders in the first..

문제 source: LeetCode Write an SQL query that selects the product id, year, quantity, and price for the first year of every product sold. Return the resulting table in any order. 제출답안(MySQL) SELECT product_id, year AS first_year, quantity, price FROM sales WHERE (product_id, year) IN (SELECT product_id, MIN(year) as first_year FROM sales GROUP BY product_id) 문제 바로가기(MySQL)

문제 source: LeetCode Write an SQL query to report the sum of all total investment values in 2016 tiv_2016, for all policyholders who: - have the same tiv_2015 value as one or more other policyholders, and - are not located in the same city like any other policyholder (i.e., the (lat, lon) attribute pairs must be unique). Round tiv_2016 to two decimal places. The query result format is in the foll..

문제 source: 프로그래머 CAR_RENTAL_COMPANY_RENTAL_HISTORY 테이블에서 대여 시작일을 기준으로 2022년 8월부터 2022년 10월까지 총 대여 횟수가 5회 이상인 자동차들에 대해서 해당 기간 동안의 월별 자동차 ID 별 총 대여 횟수(컬럼명: RECORDS) 리스트를 출력하는 SQL문을 작성해주세요. 결과는 월을 기준으로 오름차순 정렬하고, 월이 같다면 자동차 ID를 기준으로 내림차순 정렬해주세요. 특정 월의 총 대여 횟수가 0인 경우에는 결과에서 제외해주세요. 제출답안(MySQL) WITH hist_aug_thru_oct AS (SELECT *, MONTH(start_date) AS month FROM car_rental_company_rental_history WHER..
문제 source: 프로그래머 CAR_RENTAL_COMPANY_CAR 테이블과 CAR_RENTAL_COMPANY_RENTAL_HISTORY 테이블과 CAR_RENTAL_COMPANY_DISCOUNT_PLAN 테이블에서 자동차 종류가 '세단' 또는 'SUV' 인 자동차 중 2022년 11월 1일부터 2022년 11월 30일까지 대여 가능하고 30일간의 대여 금액이 50만원 이상 200만원 미만인 자동차에 대해서 자동차 ID, 자동차 종류, 대여 금액(컬럼명: FEE) 리스트를 출력하는 SQL문을 작성해주세요. 결과는 대여 금액을 기준으로 내림차순 정렬하고, 대여 금액이 같은 경우 자동차 종류를 기준으로 오름차순 정렬, 자동차 종류까지 같은 경우 자동차 ID를 기준으로 내림차순 정렬해주세요. 제출답안(My..
문제 source: 프로그래머 CAR_RENTAL_COMPANY_CAR 테이블과 CAR_RENTAL_COMPANY_RENTAL_HISTORY 테이블과 CAR_RENTAL_COMPANY_DISCOUNT_PLAN 테이블에서 자동차 종류가 '트럭'인 자동차의 대여 기록에 대해서 대여 기록 별로 대여 금액(컬럼명: FEE)을 구하여 대여 기록 ID와 대여 금액 리스트를 출력하는 SQL문을 작성해주세요. 결과는 대여 금액을 기준으로 내림차순 정렬하고, 대여 금액이 같은 경우 대여 기록 ID를 기준으로 내림차순 정렬해주세요. 제출답안(MySQL) WITH ls_truck AS(SELECT * FROM car_Rental_company_car WHERE car_type = '트럭'), rent_info AS (SEL..

문제 source: 프로그래머스 2022년 1월의 도서 판매 데이터를 기준으로 저자 별, 카테고리 별 매출액(TOTAL_SALES = 판매량 * 판매가 ) 을 구하여, 저자 ID(AUTHOR_ID), 저자명(AUTHOR_NAME), 카테고리(CATEGORY), 매출액(SALES) 리스트를 출력하는 SQL문을 작성해주세요. 결과는 저자 ID를 오름차순으로, 저자 ID가 같다면 카테고리를 내림차순 정렬해주세요. 제출답안(MySQL) WITH sales_jan2022 AS (SELECT book_id, SUM(sales) AS qty_jan2022 FROM book_sales WHERE DATE_FORMAT(sales_date, '%Y-%m') = '2022-01' GROUP BY book_id), ls_bo..

문제 source: 프로그래머 2022년 1월의 카테고리 별 도서 판매량을 합산하고, 카테고리(CATEGORY), 총 판매량(TOTAL_SALES) 리스트를 출력하는 SQL문을 작성해주세요. 결과는 카테고리명을 기준으로 오름차순 정렬해주세요. 제출답안(MySQL) SELECT category, ifnull(SUM(sales), 0) AS total_sales FROM book AS b LEFT JOIN book_sales AS bs ON b.book_id = bs.book_id WHERE DATE_FORMAT(sales_date, '%Y-%m') = '2022-01' GROUP BY category ORDER BY category 문제 바로가기(MySQL)