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

  • Home
  • SEARCH
  • 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 8687339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:05:39+00:00 2026-06-12T23:05:39+00:00

For example, i have column tables pallet_id and serial I would like to query

  • 0

For example, i have column tables pallet_id and serial

I would like to query them from

pallet_id       serial 
PA1             161
PA1             163
PA1             164
PA1             165
PA1             166
PA1             177
PA1             178
PA1             179

to

pallet_id       serial 
PA1             161-161
PA1             163-166
PA1             177-179

serials are incremented by 1 needs to stick as a range group

I just using Views as of the moment. If there is another way to do this without resulting to stored procedure, please do advise.

I am developing the SP now because I can’t find another way.

USING MSSQL2000 or lower.. 6.5? as it says here .. so no functions in this SQL Version. Upgrading is not an option too.

  • 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-12T23:05:40+00:00Added an answer on June 12, 2026 at 11:05 pm
    create table #T
    (
      ID int identity,
      pallet_id varchar(8),
      serial int
    )
    
    insert into #T(pallet_id, serial)
    select pallet_id, serial
    from YourTable
    order by pallet_id, serial
    
    select pallet_id, min(serial) min_serial, max(serial) max_serial
    from #T
    group by pallet_id, serial - ID
    
    drop table #T
    

    SQL Fiddle

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

Sidebar

Related Questions

Can I have an identity (unique, non-repeating) column span multiple tables? For example, let's
I need to get some data from a column. For example I have data
For example I have the following tables resulting from: CREATE TABLE A (Id int,
I'm trying to print out Tables from the DB that have the EntityId column
For example, I have a table, and there is a column named 'Tags'. I
I have a column of type Bit (called BBoolVal in this example). I have
For example, Lets say that I have a gridview column which has important controls,
For example I have 2 tables: topics and comments. topic has_many comments. comment belongs_to
I would like to have optimized version of my WinForms C# based application for
I have two tables which have a column in common, how can I retrieve

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.