Sort by

recency

|

951 Discussions

|

  • + 0 comments

    WITH RECURSIVE seq(n) AS ( SELECT 1 UNION ALL SELECT n+1 from seq WHERE n<20 ) SELECT REPEAT ('*',n) AS PATTERN FROM seq;

    why it is a wrong answer?

  • + 0 comments

    Oracle version:

    SELECT RPAD('* ', LEVEL * 2, '* ') FROM DUAL CONNECT BY LEVEL <=20 ;

  • + 0 comments
    DELIMITER ##
    CREATE PROCEDURE p(IN im INT)
    BEGIN
        DECLARE ic INT DEFAULT 1;
        WHILE ic <= im DO
            SELECT REPEAT('* ', ic);
            SET ic = ic + 1;
        END WHILE;
    END##
    
    DELIMITER ;
    
    -- run procedure for 20:
    CALL p(20);
    
  • + 0 comments

    my sql server

    SET @i := 0;
    
    SELECT REPEAT('* ', @i := @i + 1)
    FROM information_schema.tables
    WHERE @i < 20;
    
  • + 0 comments

    MS SQL Server

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