Sort by

recency

|

896 Discussions

|

  • + 0 comments

    with starpattern as (select 1 as num union all select num + 1 from starpattern where num<20 ) select replicate('* ', num)as stars from starpattern option(maxrecursion 0);

  • + 0 comments

    DECLARE @I INT = 1 WHILE @I <= 20 BEGIN PRINT RTRIM(REPLICATE('* ',@I)) SET @I=@I+1 END;

  • + 0 comments

    For MySQL

    DELIMITER &&
    
    CREATE PROCEDURE printPattern()
    BEGIN
        DECLARE i INT DEFAULT 1;
        
        WHILE i<=20 DO
            SELECT IF(i=1, "*", REPEAT("* ", i));
            SET i = i+1;
        END WHILE;
    
    END&&
    
    DELIMITER ;
    
    CALL printPattern();
    
  • + 0 comments

    ORACLE SQL select rpad(' ', (l)2, ' ') from (SELECT Level l FROM Dual CONNECT BY Level <= 20);

  • + 0 comments
    WITH RECURSIVE Star AS (
           SELECT 1 AS RowNums,  CAST(REPEAT('* ', 1) AS CHAR(2000)) AS Patterns
        UNION ALL
           SELECT RowNums + 1,  CAST(REPEAT('* ', rowNums + 1) AS CHAR(2000))
        FROM Star
        WHERE RowNums < 20
    )
    SELECT Patterns
    FROM Star;