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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:45:17+00:00 2026-06-08T21:45:17+00:00

I have the following data on table ID_1 ID_2 SEQ GROUP 212648 601327 1

  • 0

I have the following data on table

ID_1    ID_2    SEQ GROUP
212648  601327  1   
212648  1805    2   
212648  500886  3   
212648  3405    4   
212648  501174  5   
212648  201245  6   
212648  500449  7   
212648  3804    8   
212648  501533  9   
212648  3989    10  
212648  500280  11  START
212648  175     12  BETWEEN
212648  500395  13  END
212648  1817    14  
212648  500945  15  START
212648  183     16  BETWEEN
212648  500543  17  BETWEEN
212648  181     18  BETWEEN
212648  500009  19  END
212648  5576    20  
212648  500960  21  
212648  5562    22  
212648  603659  23  

I would like to add a column that will apply a group name for the rows between ‘START” and ‘END’.
For example:

ID_1    ID_2    SEQ GROUP   GROUP_SEQ
212648  601327  1       
212648  1805    2       
212648  500886  3       
212648  3405    4       
212648  501174  5       
212648  201245  6       
212648  500449  7       
212648  3804    8       
212648  501533  9       
212648  3989    10      
212648  500280  11  START    1
212648  175     12  BETWEEN  1
212648  500395  13  END      1
212648  1817    14      
212648  500945  15  START    2
212648  183     16  BETWEEN  2
212648  500543  17  BETWEEN  2
212648  181     18  BETWEEN  2
212648  500009  19  END      2
212648  5576    20      
212648  500960  21      
212648  5562    22      
212648  603659  23      

I searched in the analytical functions of Oracle (RANK(), FIRST, LAST() etc.) but I could not find a solution.
Thanks in advance for any responses.

  • 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-08T21:45:19+00:00Added an answer on June 8, 2026 at 9:45 pm

    Off the top, this query got the result. Probably a cleaner way if a bit more time is spent on it.

    SELECT id_1, id_2, seq, the_group
    
          ,CASE WHEN (start_count - end_count) > 0 OR (start_count = end_count AND the_group = 'END')
                THEN start_count
                ELSE NULL
           END AS group_seq
    
      FROM ( SELECT id_1, id_2, seq, the_group
    
                   ,SUM( CASE WHEN the_group = 'START' THEN 1 ELSE 0 END )
                      OVER( PARTITION BY ID_1 ORDER BY id_1, SEQ ) AS start_count
    
                   ,SUM( CASE WHEN the_group = 'END' THEN 1 ELSE 0 END )
                      OVER( PARTITION BY ID_1 ORDER BY id_1, SEQ ) AS end_count
    
               FROM myTable )
    
      ORDER BY id_1, seq
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data structure: Table 1(groups): ID | Group ============= 1 |
Lets say we have a table here, populated with the following data: acc_id1 acc_id2
Suppose we have the following table data: ID parent stage submitted 1 1 1
I have the following table: ID | JobID | Data | ResultType --------------------------------- 1
I have the following table: CREATE TABLE [dbo].[Data] ( [Id] UNIQUEIDENTIFIER NOT NULL, [Data]
I have a table with the following data: id | numbers | date ----------------------------------
Let's say I have a table containing following data: | id | t0 |
I have following table and data: create table Foo ( id int not null,
I have the following data in a table. Name LeftId RightId ------------------------------------------ Cat 1
i have the following: test <- data.table(id=1:11, t=c(rep(1:2,5), 3)) test[length(unique(id))>1,list(id, t), by=t] id t

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.