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

SQL Basics: Repeat and Reverse

daco2020 2022. 6. 7. 17:50
반응형

Using our monsters table with the following schema:

monsters table schema

  • id
  • name
  • legs
  • arms
  • characteristics

return the following table:

** output schema**

  • name
  • characteristics

Where the name is the original string repeated three times (do not add any spaces), and the characteristics are the original strings in reverse (e.g. 'abc, def, ghi' becomes 'ihg ,fed ,cba').

 

 

 

Solution:

SELECT 
  REPEAT(name,3) AS name,
  REVERSE(characteristics) AS characteristics 
FROM 
  monsters

 

 

Result:

name characteristics
CyrilCyrilCyril yllems ,gib
TinyTinyTiny duol ,yknits ,llams
NiallNiallNiall tnelutalf
UmphUmphUmph ytsan ,citoidi

 

 

 

반응형