SQL 고득점 Kit - String, Date

SQL 고득점 Kit - String, Date

프로그래머스 스쿨에서 제공하는 SQL 고득점 Kit : String, Date 입니다.

숫자는 어떻게 쓰는 건지 알겠는데, 글자와 날짜는 어떻게 다루지?

String, Date

  • LV.1
  • LV.2
  • LV.3
  • LV.4
    • 자동차 대여 기록 별 대여 금액 구하기
        SELECT 
        HISTORY_ID,
        ROUND(DAILY_FEE * RENTAL_DURATION * PURCHASE_RATE) AS FEE
        FROM (
        SELECT
            A.HISTORY_ID,
            B.DAILY_FEE,
            (DATEDIFF(A.END_DATE, A.START_DATE) + 1) AS RENTAL_DURATION,
            CASE WHEN (DATEDIFF(A.END_DATE, A.START_DATE) + 1) < 7 THEN 1
            WHEN (DATEDIFF(A.END_DATE, A.START_DATE) + 1) < 30 THEN 0.95
            WHEN (DATEDIFF(A.END_DATE, A.START_DATE) + 1) < 90 THEN 0.92
            ELSE 0.85
            END AS PURCHASE_RATE
        FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY A
        JOIN CAR_RENTAL_COMPANY_CAR B
        ON A.CAR_ID = B.CAR_ID
        WHERE B.CAR_TYPE = "트럭"
        ) A
        ORDER BY FEE DESC, HISTORY_ID DESC
      
    • 취소되지 않은 진료 예약 조회하기
        SELECT 
        A.APNT_NO, 
        B.PT_NAME,
        A.PT_NO, 
        A.MCDP_CD,
        C.DR_NAME,
        A.APNT_YMD
        FROM APPOINTMENT A
        JOIN PATIENT B ON A.PT_NO = B.PT_NO
        JOIN DOCTOR C ON A.MDDR_ID = C.DR_ID
        WHERE A.APNT_CNCL_YN = "N" 
        AND A.APNT_YMD LIKE "2022-04-13%"
        ORDER BY APNT_YMD ASC