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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:55:28+00:00 2026-06-12T20:55:28+00:00

I have a worklog table that contains the following fields: worklog_id, agent_name, ticket_number, timestamp,

  • 0

I have a worklog table that contains the following fields:

worklog_id,
agent_name,
ticket_number,
timestamp,
worklog_notes.  

I would like to be able to count the number of worklog entries made where if the agent_name, ticket_number and timestamp (date) are the same the worklog entry is only counted if the time between the two entries is greater than 1 hour.

Example: John Smith make three worklog entries on ticket 12345. The first timestamp is “10/11/2012 9:11:44 AM”, the second timestamp is “10/11/2012 9:36:16 AM” and the third timestamp is “10/11/2012 11:18:20 AM”. In this example I would only want to give the agent credit for two worklog entries as the first two were less than an hour apart.

I’ve tried getting the logic to work using a “where” sub-query, but cannot get it working. Would anyone have any example they could provide? Thanks! 🙂

  • 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-12T20:55:29+00:00Added an answer on June 12, 2026 at 8:55 pm

    Does this get what you want? The first entry by a given agent on a ticket should always be counted, and entries after that should only be counted if at least an hour has elapsed since the prior entry.

    select agent_name, ticket_number, count(*) from (
      select agent_name, ticket_number, timestamp,
             lag(timestamp) over
                (partition by agent_name, ticket_number order by timestamp) prev_timestamp
      )
    from worklog
    where (prev_timestamp is null
           or (timestamp - prev_timestamp) >= interval '1' hour
          )
    group by agent_name, ticket_number
    

    I’m not sure this is exactly what you want — if an agent keeps adding entries within an hour of the prior entry, none of them will be counted except the first. So someone who adds a lot of updates gets penalized.

    Maybe what you really want is to count the number of distinct hours in which an update was made:

    select agent_name, ticket_number, count(distinct to_char(timestamp,'DD-MON-YYYY HH24')
      from worklog
      group by agent_name, ticket_number
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table WorkLog(personId number, actionType number, doneOn timeStamp) , now how can
Have a look at the menu link Produkter on http://marckmann.se/ I would like to
Have a recurring situation, petty I know, but I'd like to consolidate the following:
have the following: // watch the fields [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTextChange:) name:UITextFieldTextDidChangeNotification object:textField1]; and
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have 2 questions : A computer with 32-bit address uses 2-level page table (9
Have a form here with bunch of input text fields and a file upload
Have a simple form that has a PictureBox in one location. I want to
Have a look at the following code to find X^y. /* Find exponent in
Have a look at one of my websites: moskah.com The problem is that it

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.