๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Programming/SQL

[HackerRank] Basic Select : Higher Than 75 Marks (MySQL)

1. ๋ฌธ์ œ ์„ค๋ช…

๋ฌธ์ œ ๋งํฌ

2. ์ฝ”๋“œ

SELECT Name
FROM STUDENTS
WHERE Marks >75
ORDER BY RIGHT(Name,3) ASC, ID ASC;
  • LEFT : ๋ฌธ์ž์—ด์˜ ์™ผ์ชฝ์„ ๊ธฐ์ค€์œผ๋กœ n๊ฐœ์˜ ๋ฌธ์ž๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ํ•จ์ˆ˜
    • LEFT(์ปฌ๋Ÿผ๋ช…, n)
  • MID : ๋ฌธ์ž์—ด์—์„œ ์ง€์ •ํ•œ ์‹œ์ž‘ ์œ„์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ n๊ฐœ์˜ ๋ฌธ์ž๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ํ•จ์ˆ˜ (= SUBSTR, SUBSTRING)
    • MID(์ปฌ๋Ÿผ๋ช…, ์‹œ์ž‘ ์œ„์น˜, n)
    • SUBSTR(์ปฌ๋Ÿผ๋ช…, ์‹œ์ž‘ ์œ„์น˜, n)
    • SUBSTRING(์ปฌ๋Ÿผ๋ช…, ์‹œ์ž‘ ์œ„์น˜, N)
  • RIGHT : ๋ฌธ์ž์—ด์˜ ์˜ค๋ฅธ์ชฝ์„ ๊ธฐ์ค€์œผ๋กœ n๊ฐœ์˜ ๋ฌธ์ž๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ํ•จ์ˆ˜
    • RIGHT(์ปฌ๋Ÿผ๋ช…, n)

3. ์ฐธ๊ณ 

https://junyoung-developer.tistory.com/47