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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:04:06+00:00 2026-05-26T19:04:06+00:00

I have a table named A. it has only one record with one field.

  • 0

I have a table named A. it has only one record with one field. It is an integer named number.
I want to create a view that have A.number records, each are one of the numbers less than A.number.

For example:

select A.number —–> 5

the view should show 5 records 0 1 2 3 4

P.S: This is a real problem that I simplified it a lot. The real problem is like dividing a budget in a fixed period to each day.

  • 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-26T19:04:07+00:00Added an answer on May 26, 2026 at 7:04 pm

    This sounds a bit like it might be homework, so I’m wary of providing the code outright.

    I can give a pointer for how to solve the question, though. You use a recursive CTE where each iteration adds one to the previous iteration. Just be sure to set the MAXRECURSION option if you’ll be checking numbers > 101. You can use a scalar sub query to key the view to the original table:


    WITH numbers ( n ) AS (
        SELECT 0 UNION ALL
        SELECT 1 + n FROM numbers WHERE n < (select number from a) -1)
    SELECT n FROM numbers
    OPTION ( MAXRECURSION 500) --example
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a self referencing table named categories that has a parentcategoryid column that
i have a table that has event name and event date. if i want
I have table called FinalForgotten which only contains one field called aname. The field
Person has two similar tables, difference is that each person has only one record
I have a user table 'users' that has fields like: id first_name last_name ...
I have a Skills table which has 14 records in it. It is structured
In my addresses table, I have an field named isPrimary. For each address assigned
I have three tables: User, Employee and Worker. User table has one-to-zero-or-one relationship with
I have two views: one is a normal view built from one table with
I have two tables named foo and bar , hypothetically speaking. foo has columns

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.