Sort by

recency

|

1206 Discussions

|

  • + 0 comments

    My solution SQL SERVER:

    Declare @Count Tinyint = '20' WHILE @Count >= 1 begin print replicate('* ',@Count) Set @Count = @Count-1 end;

  • + 0 comments

    dont forget the space guys "* "

  • + 0 comments

    Oracle: WITH T1 AS ( SELECT LEVEL lvl FROM DUAL CONNECT BY LEVEL <= 20 ORDER BY LEVEL DESC ) SELECT RPAD('* ', lvl*2, '* ') FROM T1;

  • + 0 comments

    FOR SQL SERVER with starpattern as ( select 20 as num union all select num -1 from starpattern where num>1 ) select replicate('* ',num)as stars from starpattern option(maxrecursion 0);

  • [deleted]
    + 0 comments

    For MySQL

    DELIMITER $$
    
    CREATE PROCEDURE printPattern()
    BEGIN
        DECLARE i INT DEFAULT 20;
        
        WHILE i>0 DO
            SELECT IF(i=1, "*", REPEAT("* ", i));
            SET i = i-1;
        END WHILE;
    END$$
    
    DELIMITER ;
    
    CALL printPattern();