TIL

2024.11.14

죵욜이 2024. 11. 15. 17:13

오늘은 강의를 다들어서 문제풀이를 집중적으로 했다.

 

 

 

이문제들을 풀었는데

 

SQL 은 이렇게

#1
SELECT PT_NAME,
       PT_NO,
       GEND_CD,
       AGE,
       if(TLNO is NULL, "NONE", TLNO) TLNO
FROM PATIENT
WHERE age <= 12
      AND GEND_CD = "W"
ORDER BY age DESC,
         PT_NAME
         
#2
SELECT DR_NAME,
       DR_ID,
       MCDP_CD,
       DATE_FORMAT(HIRE_YMD, "%Y-%m-%d")
FROM DOCTOR
WHERE MCDP_CD = "CS"
      OR MCDP_CD = "GS"
ORDER BY HIRE_YMD DESC,
         DR_NAME
         
#3
SELECT FLAVOR
FROM FIRST_HALF
ORDER BY TOTAL_ORDER DESC,
         SHIPMENT_ID

#4
SELECT fh.FLAVOR
FROM FIRST_HALF fh
     LEFT JOIN ICECREAM_INFO ii ON fh.FLAVOR = ii.FLAVOR
WHERE fh.TOTAL_ORDER > 3000
      AND ii.INGREDIENT_TYPE = "fruit_based"
ORDER BY fh.TOTAL_ORDER DESC

#5
SELECT BOOK_ID,
       DATE_FORMAT(PUBLISHED_DATE, "%Y-%m-%d")
FROM BOOK
WHERE DATE_FORMAT(PUBLISHED_DATE,"%Y") = "2021"
      AND CATEGORY = "인문"
ORDER BY PUBLISHED_DATE

 

 

Python 은

#1 (3점)
def solution(num, n):
    answer = 0
    
    if num % n == 0 :
        answer = 1
    return answer

#2 (10점)
def solution(number, n, m):
    answer = 0
    
    if number % n == 0 and number % m ==0 :
        answer = 1
    return answer

#3 (5점)
def solution(n):
    answer = 0
    
    if n % 2 == 1:
        for i in range(1, n+1, 2):
            answer += i
    else :
        for i in range(2, n+1, 2):
            answer += i*i
    return answer

#4 (12점)
def solution(ineq, eq, n, m):
    answer = 0
    
    # 문자열로 들어온 비교연산자(key)를 실제연산을 한 boolean 값(value)을
    # 가지는 딕셔너리 선언
    compare_dict = {      
        ">=" : n >= m,
        "<=" : n <= m,
        ">!" : n > m,
        "<!" : n < m
    }
   
    if compare_dict[ineq + eq]:
        answer = 1
    
    return answer

#5 (1점)
def solution(a, b, flag):
    answer = 0
    
    if flag :
        answer = a + b
    else :
        answer = a - b
    return answer

 

이렇게 풀었다.

 

오늘 DATE_FORMAT 과 range() , eval() 등 많은걸 배웠지만 시간이 별로없어서 주말동안 정리해볼 예정이다.

'TIL' 카테고리의 다른 글

[WIL] 본캠프 1주차  (2) 2024.11.30
2024.11.21  (2) 2024.11.21
2024.11.13  (1) 2024.11.14
2024.11.10  (4) 2024.11.10
2424.11.08  (3) 2024.11.09