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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:52:06+00:00 2026-06-09T13:52:06+00:00

I have a table SUB_Inst with columns id, low and high. How would I

  • 0

I have a table SUB_Inst with columns id, low and high. How would I query the low and high numbers returning a new column with a record for each number from low to high?

    Current table SUB_Inst
    id  low High
    1   55  63
    2   232 234
    3   4   7
    etc.

Desired Results

    id    low    High   Num_list
    1     55     63     55
    1     55     63     56
    1     55     63     57
    1     55     63     58
    1     55     63     59
    1     55     63     60
    1     55     63     61
    1     55     63     62
    1     55     63     63
    2     232    234    232
    2     232    234    233
    2     232    234    234
    3     4      7      4
    3     4      7      5
    3     4      7      6
    3     4      7      7
    etc.

I tried something like this:

    SELECT Low, HIGH,
    (SELECT CAST(number as varchar)+','
    FROM NUMBERS
    WHERE number >= Low and number <= High 
    FOR XML PATH(''))
    FROM SUB_Inst

but it returned all the numbers in one field like this which won’t work:

    Low       High             Num_List
    24   27         24,25,26,27,
    34   36         34,35,36,
    10   17         10,11,12,13,14,15,16,17,
    34   36         34,35,36,
    65   67         65,66,67,
    502      504        502,503,504,
    56   59         56,57,58,59,

Thank you.

  • 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-09T13:52:07+00:00Added an answer on June 9, 2026 at 1:52 pm

    I think you want this :

    SELECT id,low,high,number as Num_List
    FROM SUB_Inst , NUMBERS
    where low<=number and high>=number 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table where each row has a category column and a sub-category
I have table and this table contain result column with some entries. I just
I have table with 300 000 records (MyISAM). I get record from this table
I have a table that is formatted like so: New York -> ALBANY ->
I have table tree. I have query: SELECT * FROM tree WHERE pid =10
I have a table with 1,000,000+ records and I would like to find the
I have a table TableA with a computed column FieldA bound to a function
I have a table with three columns: id , ref and catName . Every
Hi I have a table that have timestamp column. I want to update a
I have a table set up with a column titled has_sub which contains a

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.