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

The Archive Base Latest Questions

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

I have a trace table which looks like this I’d like to get a

  • 0

I have a trace table which looks like this

TraceTable

I’d like to get a running total which looks like the following output – its very important that I retain the order – as this is the execution order of the stored porcedures – It will help me analyze bottle necks in the system

Output

I have tried

select max(RowNumber),objectname, count(1) from rob
where eventclass = 42
group by objectname

But that mucks up the order

Is this even possible in SQL?

UPDATE:
I tried this

select RowNumber,objectname, count(1) from rob
where eventclass = 42
group by objectname,RowNumber
order by RowNumber

But this (as the query quite rightly says groups by rownumber (have to have that to have it in the order by) )

  • 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-09T12:45:01+00:00Added an answer on June 9, 2026 at 12:45 pm
    select objectname, 
           count(*)
    from (
         select RowNumber,
                objectname,
                row_number() over(order by RowNumber) - row_number() over(order by objectname, RowNumber) as grp
         from rob
         where eventclass = 42
         ) as T
    group by grp, objectname
    order by min(RowNumber)
    

    Working sample using a table variable.

    declare @T table
    (
      RowNumber int,
      objectname varchar(50)
    )
    
    insert into @T values
    (8, 'f_system_log_init'),
    (10, 'f_purge_system_log'),
    (25, 'f_system_log_msg'),
    (65, 'f_system_log_msg'),
    (104, 'f_system_log_msg'),
    (143, 'f_system_log_msg'),
    (182, 'f_system_log_msg'),
    (221, 'f_system_log_msg'),
    (5015, 'f_get_system_logs_parent_log_id_for_dataloader'),
    (5055, 'f_system_log_msg'),
    (5096, 'f_system_log_msg')
    
    select objectname, 
           count(*)
    from (
         select RowNumber,
                objectname,
                row_number() over(order by RowNumber) - row_number() over(order by objectname, RowNumber) as grp
         from @T
         ) as T
    group by grp, objectname
    order by min(RowNumber)
    

    Result:

    objectname                                         
    -------------------------------------------------- -----------
    f_system_log_init                                  1
    f_purge_system_log                                 1
    f_system_log_msg                                   6
    f_get_system_logs_parent_log_id_for_dataloader     1
    f_system_log_msg                                   2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that looks like this: <table name=exercises id=workout-table> <tr> <th>Name</th> <th>Reps/Intervals</th>
I have a table of data that looks like the following: ArtistName TrackName TrackID
I have two tables which look like this: T1: T1ID | Date | Time
I have two simple tables in Django which looks like: class Session(models.Model): id =
I have a database with a single table right now, which contains the following
I have some data in a field that looks like this boston,11/7/10,11/12/10,11/13/10 atlanta,11/11/10,11/15/10,11/18/10 and
I have the following stack trace from valgrind. But it does not give me
I have the following stack trace. Is it possible to make out anything useful
My Core Data model looks like this: alt text http://fwdr.org/lg4q The players relationship of
This is to be an application-agnostic question, but one I'd like to get 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.