Generate rows

From SQLZOO
Jump to navigation Jump to search

Here you are shown how to generate rows without the use of tables

schema:scott

You can use single value SELECT to generate tables

You can use them when you need a small table for your query but you don't have permission to create tables in the database itself.

SELECT x centigrade, x*9/5+32 fahrenheit
  FROM  (SELECT 0 x UNION SELECT 10 UNION SELECT 20
                    UNION SELECT 30 UNION SELECT 40) t
SELECT x centigrade, x*9/5+32 fahrenheit
  FROM (      SELECT  0 x FROM dual
        UNION SELECT 10   FROM dual
        UNION SELECT 20   FROM dual
       UNION SELECT 30   FROM dual
       UNION SELECT 40   FROM dual) t
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects