We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Draw The Triangle 1
Draw The Triangle 1
Sort by
recency
|
1221 Discussions
|
Please Login in order to post a comment
Declare @i As int =20; Declare @tbl As Table (myStr varchar(max)) Declare @str As varchar(max) While(@i>0) Begin Set @str = REPLICATE('* ',@i); Insert into @tbl(myStr) values (@str) Set @i = @i-1 End select * from @tbl
select ('* * * * * * * * * * * * * * * * * * * '); select (' * * * * * * * * * * * * * * * * * '); select (' * * * * * * * * * * * * * * * * '); select (' * * * * * * * * * * * * * * * '); select (' * * * * * * * * * * * * * * '); select (' * * * * * * * * * * * * * '); select (' * * * * * * * * * * * * '); select (' * * * * * * * * * * * '); select (' * * * * * * * * * * '); select (' * * * * * * * * * '); select (' * * * * * * * * '); select (' * * * * * * * '); select (' * * * * * * '); select (' * * * * * '); select (' * * * * '); select (' * * * '); select (' * * '); select (' * '); select (' '); select ('');
what's wrong with this SQL query output coming correct but use case failed. declare @countercheck int; set @countercheck=20; while(@countercheck>0) begin select REPLICATE('*',@countercheck) set @countercheck=@countercheck-1; end
MYSQL
WITH RECURSIVE Pattern AS ( SELECT 20 AS num UNION ALL SELECT num - 1 FROM Pattern WHERE num > 1 ) SELECT REPEAT('* ', num) FROM Pattern;