Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[프로그래머스/SQL 고득점 Kit] String, Date #45

Open
sieunnnn opened this issue Dec 20, 2023 · 3 comments
Open

[프로그래머스/SQL 고득점 Kit] String, Date #45

sieunnnn opened this issue Dec 20, 2023 · 3 comments
Assignees
Labels
SQL SQL 문제풀이 프로그래머스 프로그래머스 문제풀이

Comments

@sieunnnn
Copy link
Owner

sieunnnn commented Dec 20, 2023

프로그래머스 SQL 고득점 Kit String, Date 문제풀이 입니다.

@sieunnnn
Copy link
Owner Author

sieunnnn commented Jan 8, 2024

자동차 평균 대여 기간 구하기

날짜 기간 구하기

DATEDIFF(end_date, start_date)

@sieunnnn
Copy link
Owner Author

sieunnnn commented Jan 8, 2024

중성화 여부 파악하기

IF (첫번째 조건 OR 두번째 조건, 첫번째 조건의 결과, 두번째 조건의 결과)

@sieunnnn
Copy link
Owner Author

sieunnnn commented Jan 9, 2024

조회수가 가장 많은 중고거래 게시판의 첨부파일 조회하기

CONCAT()

문자열을 합칠 때 사용합니다.

CONCAT('/home/grep/src/', F.BOARD_ID, '/', F.FILE_ID, F.FILE_NAME, F.FILE_EXT) AS FILE_PATH

처음 작성한 방식

SELECT CONCAT('/home/grep/src/', F.BOARD_ID, "/",F.FILE_ID,F.FILE_NAME, F.FILE_EXT) AS FILE_PATH
FROM USED_GOODS_BOARD AS B
         JOIN USED_GOODS_FILE AS F
              ON B.BOARD_ID = F.BOARD_ID
ORDER BY VIEWS DESC LIMIT 1;
  • 이렇게 작성하면 뷰가 최대인 게시글에 해당하는 여러 첨부파일 중 한개만 결과로 나오게 됩니다.
  • 여러파일이 나와야 하므로 이 방법은 적절하지 못합니다.
  • 또한 또다른 정렬이 있는데, 그 정렬은 후순위로 밀려서 어쨌거나 저쨌거나 맞는 방식이 아닙니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SQL SQL 문제풀이 프로그래머스 프로그래머스 문제풀이
Projects
None yet
Development

No branches or pull requests

1 participant