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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:45:37+00:00 2026-06-13T02:45:37+00:00

In a SQL SERVER 2005 database, please suppose we have a table called RUNNING_COLA_IS_AFRICA.

  • 0

In a SQL SERVER 2005 database, please suppose we have a table called RUNNING_COLA_IS_AFRICA.

This table has a unique varchar(50) field called RUNNING_ID.

We have 1 million records in this table.

I would like to write a query that, sorting by RUNNING_ID ASC, and stating a range of 50, produces an output similar to the following:

RUNNING_ID_START RUNNING_ID_END
000000           000103
000104           000767
000892           001492
001576           011222
012345           013579

This means that:

a) The number of the records between 000000 and 000103 is 50;
b) The number of the records between 000104 and 000767 is 50;
c) The number of the records between 000892 and 001492 is 50;
d) The number of the records between 001576 and 011222 is 50;
e) The number of the records between 012345 and 013579 is <= 50.

Of course, min(RUNNING_ID) = 000000 and max(RUNNING_ID) = 013579 because they are ordered by RUNNING_ID ASC.

How could I achieve this in SQL SERVER 2005?

Thank you in advance for your kind help.

  • 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-13T02:45:38+00:00Added an answer on June 13, 2026 at 2:45 am
    WITH
      sequenced
    AS
    (
      SELECT
        ROW_NUMBER() OVER (ORDER BY running_id) - 1 AS sequence_id,
        *
      FROM
        RUNNING_COLA_IS_AFRICA
    )
    SELECT
      sequence_id / 50     AS group_id,
      MIN(running_id)      AS running_id_first,
      MAX(running_id)      AS running_id_last,
      COUNT(*)             AS size_of_group
    FROM
      sequenced
    GROUP BY
      sequence_id / 50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following scenario in my SQL Server 2005 database. zipcodes table has
I have a SQL Server 2005 database that has been deleted, and I need
I have a junction table in my SQL Server 2005 database that consist of
I have created views on the SQL Server 2005 database and this view is
I have a SQL database table column which has data in this format 0000-00-0000
I have a SQL Server 2005 database hosted on a shared hosting environment. Unfortunately
I am looking at a large-ish SQL Server 2005 database, that has entered into
I have data in an SQL Server 2005 database which I need to copy
We have two tables in a SQL Server 2005 database, A and B.There is
I have a SQL Server 2005 database comprised of Customers , Quote , QuoteDetail

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.