Draw The Triangle 1 in SQL | HackerRank Solution

Hello coders, today we are going to solve Draw The Triangle 1 HackerRank Solution in SQL.

Draw The Triangle 1

Problem

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).

Solution – Draw The Triangle 1 in SQL

MySQL

SELECT REPEAT('* ', @NUMBER := @NUMBER - 1) FROM information_schema.tables, (SELECT @NUMBER:=21) t LIMIT 20

Disclaimer: The above Problem (Draw The Triangle 1) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

Leave a Comment

Your email address will not be published. Required fields are marked *