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

The Archive Base Latest Questions

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

I’d like to get a count of how many times a process code of

  • 0

I’d like to get a count of how many times a process code of 20 has a LastModifiedTime before a process code of 10 for each WorkflowId grouping.

This query shows the table layout and some data:

SELECT TOP 10 * 
FROM master.ProcessLogging with (nolock) 
WHERE ProcessCode = 10 OR ProcessCode = 20 
ORDER BY WorkflowId, ProcessCode

enter image description here

I’ve tried a few things, but I’m having a difficult time getting it to work. Each attempt has lead to a dead end that’s not worth posting here. Is there a way to see all of the times a 20 comes before a 10? And maybe even see the time difference between them?

  • 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-11T23:56:06+00:00Added an answer on June 11, 2026 at 11:56 pm

    Upon review this will break if more than one 10 in a group

    Will there ever be more than 10 in a group and if so how do you want it handled?

    SELECT p10.WorkflowId, count(p20.WorkflowId)
    FROM master.ProcessLogging p10 
    left outer join master.ProcessLogging p20
      on  p20.WorkflowId = p10.WorkflowId
      and p20.EventTime < p10.EventTime
      and p20.ProcessCode = 20
    where p10.ProcessCode = 10 
    group by p10.WorkflowId 
    order by p10.WorkflowId
    

    — Edit from Bob Horn —

    Slightly modified above query to show the largest time difference between the 10s and 20s.

    SELECT p10.WorkflowId, min(p20.WorkflowId), 
           DATEDIFF(ms, min(p10.lastmodifiedtime), min(p20.lastmodifiedtime)) as 'Diff (ms)'
    FROM master.ProcessLogging p10 
    join master.ProcessLogging p20
      on  p20.WorkflowId = p10.WorkflowId
      and p20.EventTime < p10.EventTime
      and p20.ProcessCode = 20
    where p10.ProcessCode = 10 
    group by p10.WorkflowId 
    order by ABS(DATEDIFF(ms, min(p10.lastmodifiedtime), min(p20.lastmodifiedtime))) DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get a count of how many times a substring occurs
I've been trying to count how many times a tag has been entered into
So I want to get the count of the missed calls like the telephonyapplication
I would like to get numbers of comments for each posts using mysql. I
This is a particular problem that I have come across many times, but I
I have a collections.defaultdict(int) that I'm building to keep count of how many times
I'd like to use Cassandra to store a counter. For example how many times
please take a look of this query: SELECT DATE(datetime), COUNT(1) as numVisits FROM .table_stats.
Im trying to get a count on how many people live in a certain
What I need is query that show : How many times value in field

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.