나는 이렇게 학습한다/Algorithm & SQL

Returning Strings

daco2020 2022. 5. 20. 21:20
반응형

Write a select statement that takes name from person table and return "Hello, how are you doing today?" results in a column named greeting

[Make sure you type the exact thing I wrote or the program may not execute properly]

 

 

Solution:

SELECT concat('Hello, ', name, ' how are you doing today?') 
AS greeting 
FROM person

concat appends string arguments.

'||' By using symbols, the same result can be achieved.

SELECT 'Hello, ' || name || ' how are you doing today?' 
AS greeting 
FROM person

 

 

 

Result:

greeting
Hello, Tim DuBuque how are you doing today?
Hello, Jessie Hodkiewicz how are you doing today?
Hello, Casandra Blick LLD how are you doing today?
Hello, Mrs. Don Stiedemann how are you doing today?
Hello, Gaynell Schmeler how are you doing today?
Hello, Numbers Bins how are you doing today?
Hello, Amb. Justa Koch how are you doing today?
Hello, Miss Cristobal Cummings how are you doing today?
Hello, Earnestine Murray how are you doing today?
Hello, Ben Morissette how are you doing today?

 

 

 

반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

Beginner Series #2 Clock  (0) 2022.05.22
SQL Basics: Simple SUM  (0) 2022.05.21
Even or Odd  (0) 2022.05.19
SQL Basics: Simple DISTINCT  (0) 2022.05.18
Easy SQL: Square Root and Log  (0) 2022.05.17