Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORACLE SQL:Get all integers between two numbers

Is there any way to select the numbers (integers) that are included between two numbers with SQL in Oracle; I don't want to create PL/SQL procedure or function.

For example I need to get the numbers between 3 and 10. The result will be the values 3,4,5,6,7,8,9,10.

Thx.


1 Answers

This trick with Oracle's DUAL table also works:

SQL> select n from
  2  ( select rownum n from dual connect by level <= 10)
  3  where n >= 3;

         N
----------
         3
         4
         5
         6
         7
         8
         9
        10
like image 117
Tony Andrews Avatar answered Sep 12 '25 20:09

Tony Andrews