Advanced Select
Last updated
Was this helpful?
Last updated
Was this helpful?
Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:
Equilateral: It's a triangle with sides of equal length.
Isosceles: It's a triangle with sides of equal length.
Scalene: It's a triangle with sides of differing lengths.
Not A Triangle: The given values of A, B, and C don't form a triangle.
Input Format
The TRIANGLES table is described as follows:
Each row in the table denotes the lengths of each of a triangle's three sides.
SQL์์์ ๋ถ๊ธฐ๋ฌธ์ ์น๋ ๋ฐฉ๋ฒ์
CASE, WHEN-THEN, ELSE, END
WHEN์๋ ์กฐ๊ฑด๊ฐ์, THEN์๋ ๊ฒฐ๊ณผ๊ฐ์ ๋ฃ์ด์ฃผ๋ฉด๋๋๋ฐ, ๋ฆฌํด๊ฐ์๋ null๊ฐ์ด ๋ค์ด๊ฐ ์ ์๋ค๋ ์ ๊ธฐ์ต
๊ธฐ๋ณธ์ ์ผ๋ก if-else์ ๋ฐฉ์์ด๋ผ๊ณ ์๊ฐํ๋๋ฐ, switch๋ฌธ ์ฒ๋ผ ์ฌ์ฉํ๊ณ ์ถ๋ค๋ฉด
CASE ๋ค์ switch์์ ๊ฒ์ฌํ ํญ๋ชฉ์ด ๋ฌด์์ธ์ง ์ ์ด์ฃผ๊ณ , WHEN์๋ ๊ทธ๋ฅ ํญ๋ชฉ์ ๋ํ ๊ฐ์ ์ ์ด์ฃผ๋ฉด ๋๋ค
๋ญ๊ฐ ์์ด๋ฅผ ๋๋ฌด ์ผ๋ผ์ผ๋ผ ์ฌ์... ๋ฒ์ญ๊ธฐ๋ฅผ ์ฌ์ฉํด์ ์งํ
OCCUPATIONS์ ๋ชจ๋ ์ด๋ฆ์ ์ํ๋ฒณ ์์ผ๋ก ๋์ดํ๊ณ , ๋์ดํ ๋ ๊ฐ ์ง์ ์ ์ฒซ ๊ธ์๋ฅผ ๊ดํธ๋ก ๋ฌถ์ด์ ์ถ๋ ฅํ๋ผ
OCCUPATIONS์์ ๋์จ ๊ฐ ์ง์ ์ ๊ฐฏ์๋ฅผ 'There are a total of [์ซ์] [์ง์ ]s' ์ด ํฌ๋งท์ผ๋ก ์ถ๋ ฅํ๋ผ
๋งํ๋ ๋ถ๋ถ์ SELECT ๋ฌธ์์ ๋ฌธ์์ด์ ๋ํ๋ ๊ฒ์ด์๋๋ฐ...
SQL์์๋ ๋ฌธ์์ด + ์ ||๋ก ํํํ๋ค๋ ๊ฒ์ ์๊ฒ๋์๋ค...!
COUNT, UPPER, LOWER, SUBSTR๋ ๊ธฐ์กด์ ํ๋๊ฒ ๊ธฐ์ต๋๋๋ผ