본문 바로가기

컴퓨터과학/Algorithm

[SQL] [Codewars] 7Kyu - Hello SQL World!

 

Codewars: Achieve mastery through challenge

Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.

www.codewars.com

문제

Hello SQL!

 

Return a table with a single column named Greeting with the phrase 'hello world!'

 

코드

SELECT 'hello world!' as "Greeting"

 

설명

SQL에서 문자열을 출력하는데 SELECT를 사용할 수 있다. 출력할 문자열은 작은따옴표로 묶어줘야 한다.

또한, SQL에서 컬럼 별칭을 작성한 그대로 표시하려면 큰따옴표로 묶어줘야 한다. 아래와 같이 칼럼명을 작성하면 모조리 소문자로 출력된다.

SELECT 'hello world!' as Greeting