CodingSpace

[HackerRank/SQL] Alternative Queries - Draw The Triangle 2 본문

HackerRank/SQL

[HackerRank/SQL] Alternative Queries - Draw The Triangle 2

개발자_조이킴 2022. 7. 22. 08:40

Problem. Alternative Queries - Draw The Triangle 2


Link.

https://www.hackerrank.com/challenges/draw-the-triangle-2/problem?isFullScreen=true 

 

Draw The Triangle 2 | HackerRank

Draw the triangle pattern using asterisks.

www.hackerrank.com


Description.

P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):

Write a query to print the pattern P(20).


Key Point. 

REPEAT,


My Answer. 

SET @number := 0;
SELECT REPEAT('* ', @number := @number + 1) 
FROM information_schema.tables
WHERE @number <= 19;

References. 

Comments