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 9310985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:15:05+00:00 2026-06-19T01:15:05+00:00

From the table: | name | range | ———————— | ‘Range1’ | ‘456-458’ |

  • 0

From the table:

|   name   |   range   |
------------------------
| 'Range1' | '456-458' |
| 'Range2' |   '11-13' |

just trying to get this result:

|   name   |   range   | value |
--------------------------------
| 'Range1' | '456-458' |  456  |
| 'Range1' | '456-458' |  457  |
| 'Range1' | '456-458' |  458  |
| 'Range2' |   '11-13' |   11  |
| 'Range2' |   '11-13' |   12  |
| 'Range2' |   '11-13' |   13  |

made ​​the query which works fine if the source table has only one range:

WITH data AS (
    SELECT 'Range1' name, '456-458' range FROM dual
)
SELECT ROWNUM, name, range, LEVEL value
FROM data, dual
WHERE LEVEL >= to_number(SUBSTR(range, 1, INSTR(range,'-')-1))
CONNECT BY LEVEL <= to_number(SUBSTR(range, INSTR(range,'-')+1));

but returns tens of thousands of rows, if takes two ranges:

WITH data AS (
    SELECT 'Range1' name, '456-458' range FROM dual
    UNION
    SELECT 'Range2' name, '11-13' range FROM dual
)
SELECT ROWNUM, name, range, LEVEL value FROM data, dual
WHERE LEVEL >= to_number(SUBSTR(range, 1, INSTR(range,'-')-1))
CONNECT BY LEVEL <= to_number(SUBSTR(range, INSTR(range,'-')+1));

Is it possible to improve this query to get the required, or my approach is wrong initially?

Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
  • 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-06-19T01:15:06+00:00Added an answer on June 19, 2026 at 1:15 am

    in 11g you can use a recursive factored sub query for this type of thing.

    SQL> with data as (select name, range,
      2                       to_number(substr(range, 1, instr(range,'-')-1)) from_val,
      3                       to_number(substr(range, instr(range,'-')+1)) to_val
      4                  from your_table),
      5  ranges (name, range, curr_val, from_val, to_val)
      6  as (select name, range, from_val, from_val, to_val
      7        from data
      8      union all
      9      select name, range, curr_val+1, from_val, to_val
     10        from ranges
     11       where curr_val < to_val)
     12  select name, range, curr_val
     13    from ranges
     14   order by name, curr_val;
    
    NAME   RANGE     CURR_VAL
    ------ ------- ----------
    Range1 456-458        456
    Range1 456-458        457
    Range1 456-458        458
    Range2 11-13           11
    Range2 11-13           12
    Range2 11-13           13
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here am trying to get values from a mysql table with the name lead.
i have this sql query select * from table where name like ? but
I need to change table name from lowercase to uppercase but using this statement
I want to get range ranking from a table using mysql query. the table
When using this SQL query: Select * from table_name what happens if the name
Using VB6 and Access 2003 Query Select Temp.* into NewTable from Temp Table Name
Usually, I need to retrieve data from a table in some range; for example,
I have to fetch data from a running-time-defined table and get data based on
retrieving items from table that fall between a date range. the date (db table
If I want to fetch records from a table (table name is dynamic from

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.