250x250
Link
๋‚˜์˜ GitHub Contribution ๊ทธ๋ž˜ํ”„
Loading data ...
Notice
Recent Posts
Recent Comments
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Data Science LAB

[MySQL] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต6(๋‹ค์ค‘ ์ •๋ ฌ) ๋ณธ๋ฌธ

๐Ÿ“ Coding Test/MySQL

[MySQL] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต6(๋‹ค์ค‘ ์ •๋ ฌ)

ใ…… ใ…œ ใ…” ใ…‡ 2022. 2. 13. 01:03
728x90
๋ฌธ์ œ
ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. 
ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, 
ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE
๋Š” ๊ฐ๊ฐ ๋™๋ฌผ์˜ ์•„์ด๋””, ์ƒ๋ฌผ ์ข…, ๋ณดํ˜ธ ์‹œ์ž‘์ผ, ๋ณดํ˜ธ ์‹œ์ž‘ ์‹œ ์ƒํƒœ, ์ด๋ฆ„, ์„ฑ๋ณ„ ๋ฐ ์ค‘์„ฑํ™” ์—ฌ๋ถ€๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.

๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋ชจ๋“  ๋™๋ฌผ์˜ ์•„์ด๋””์™€ ์ด๋ฆ„, ๋ณดํ˜ธ ์‹œ์ž‘์ผ์„ ์ด๋ฆ„ ์ˆœ์œผ๋กœ ์กฐํšŒํ•˜๋Š” SQL๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ๋‹จ, ์ด๋ฆ„์ด ๊ฐ™์€ ๋™๋ฌผ ์ค‘์—์„œ๋Š” ๋ณดํ˜ธ๋ฅผ ๋‚˜์ค‘์— ์‹œ์ž‘ํ•œ ๋™๋ฌผ์„ ๋จผ์ € ๋ณด์—ฌ์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

 

์˜ˆ์‹œ

 

 

 

๋ฌธ์ œ ํ’€์ด
SELECT ANIMAL_ID, NAME, DATETIME
FROM ANIMAL_INS
ORDER BY NAME ASC,DATETIME DESC

ORDER BY ์ ˆ์€ ์—ด์„ ์ •๋ ฌํ•˜๋Š” ๋ฐ์— ์‚ฌ์šฉ, ์กฐ๊ฑด์ด ์—ฌ๋Ÿฌ๊ฐœ์ด๋ฉด ,๋กœ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Œ

 

  ASC DESC
์ˆซ์ž ์ž‘์€ ๊ฐ’๋ถ€ํ„ฐ ํฐ ๊ฐ’๋ถ€ํ„ฐ
๋ฌธ์ž A๋ถ€ํ„ฐ ์‚ฌ์ „ ๋ฐ˜๋Œ€๋ถ€ํ„ฐ
๋‚ ์งœ ๋น ๋ฅธ ๋‚ ์งœ๋ถ€ํ„ฐ ๋Šฆ์€ ๋‚ ์งœ๋ถ€ํ„ฐ
NULL ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ๊ฐ€์žฅ ๋จผ์ €
728x90
Comments