Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3274046
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:59:46+00:00 2026-05-17T18:59:46+00:00

I have a table1(startnumber, endnumber) in oracle; Now I need to select all the

  • 0

I have a table1(startnumber, endnumber) in oracle;

Now I need to select all the numbers lies in between startnumber and endnumber from table1

data eg.

    table1
   startnumber      endnumber
     10                15
    18                 22
    34                 50

Now I need the result set as:

10,11,12,13,14,15,18,19,20,21,22,34,35..... and so on

How do i do that

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:59:46+00:00Added an answer on May 17, 2026 at 6:59 pm

    if you wanted the values comma separated you could do as such (or if on 11gr2 use listAgg)

    WITH NUMS AS(
         SELECT 10 STARTNR  , 15 ENDNR  FROM DUAL UNION
        SELECT 18 STARTNR  , 22 ENDNR  FROM DUAL UNION
        SELECT 34 STARTNR  , 50 ENDNR  FROM DUAL )       , 
     NUMSBETWEEN AS(
         SELECT distinct (level + startnr)-1 seq , startnr, endnr
           FROM NUMS
          CONNECT BY (LEVEL +STARTNR ) <= ENDNR+1
          )
    SELECT startnr,
           LTRIM(MAX(SYS_CONNECT_BY_PATH(seq,','))
           KEEP (DENSE_RANK LAST ORDER BY curr),',') AS seq
    FROM   (SELECT startnr,
                   seq,
                   ROW_NUMBER() OVER (PARTITION BY startnr ORDER BY seq) AS curr,
                   ROW_NUMBER() OVER (PARTITION BY startnr ORDER BY seq) -1 AS prev
            FROM   numsBetween)
    GROUP BY startnr
    CONNECT BY prev = PRIOR curr AND startnr = PRIOR startnr
    START WITH CURR = 1;
    

    STARTNR SEQ


    10 10,11,12,13,14,15
    18 18,19,20,21,22
    34 34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider I have such SQL query: SELECT t1.* FROM table1 t1 LEFT JOIN table2
I have table1 (col1,col2) and table2(col1,col2) as given below/ Now i need to replace
I have the following query: SELECT rowid FROM table1 ORDER BY RANDOM() LIMIT 1
I have two tables, I'll call TableA and TableB TableA: StartNumber EndNumber Country 1
I have table1 on which I do this query SELECT DATE_FORMAT(FROM_UNIXTIME(t.TSTAMP), %Y-%m) AS timePeriod,
What I need to do is get a table name in result from a
I currently have a table that exists which I'm able to pull data from.
I have a stored procedure that takes data from multiple tables. The stored procedure
I have Table1 and I need to get it to look like Table2: Table1
I have table1 which is being updated and inserted with data via sp's .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.