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
|
1196 Discussions
|
Please Login in order to post a comment
Declare @vik int = 20 while @vik >= 1 Begin Print Replicate ('* ', @vik) Set @vik = @vik - 1 End
WITH RECURSIVE series AS ( SELECT 1 AS number -- Starting value UNION ALL SELECT number + 1 FROM series WHERE number < 20 -- Ending value )
SELECT REPEAT('* ', number) FROM series ORDER BY number DESC;
SET @NUMBER = 21; SELECT REPEAT('* ', @NUMBER := @NUMBER - 1) FROM information_schema.tables WHERE @NUMBER > 1;
ORACLE SQL
SELECT RPAD('* ', ((20*2)+1) - LEVEL*2, '* ') AS stars FROM dual CONNECT BY LEVEL <= 20;
I wrote the below in sql server to solve this. The output is as expected but i still get some 'run time error'. i wonder why!!
create procedure triangle as declare @i int declare @j int
set @i=1 set @j=20
while @j>=@i begin print replicate ('*', @j) set @j=@j-1 end
execute triangle