• 0

[SQL] Group by Transaction within an hour


Question

I am trying to track when a user calls in to change enrollment information with the help of a staff member.

I am trying to write a query that will track calls made. In a single call, there can be multiple transactions performed. I have a transaction table which I need to count unique calls.

I am having trouble figuring out how to group these transaction. I want to group by transactions per customer within an hour.

For example, transaction for performed by one staff member made to a single customer could look like this. There are 3 unique calls for this customer

STAFF MEMBER | CUSTOMER| TRANSACTION DATE

JIM | JON| 2008-07-02 09:02:18.000 -- 1st call

JIM | JON| 2008-07-02 09:02:20.000 -- 1st call

JIM | JON| 2008-07-02 09:02:22.000 -- 1st call

JIM | JON| 2008-07-02 09:03:19.000 -- 2nd call (hour after first transaction of 1st call)

JIM | JON| 2008-07-02 09:04:22.000 -- 2nd call (hour after first transaction of 2nd call)

any thoughts on how the group would work so I get back only the first transactions of the unique call?

5 answers to this question

Recommended Posts

  • 0

Are those the only fields in that table?

There doesnt seem to be enough unique information that would be needed to break down the data further into 1st call, 2nd call etc.. or what action was performed. Without this there is no way of knowing whats a first call and whats a subsequent call - its just a list of times in a table with no contextual info

  • 0
  ramesees said:
Are those the only fields in that table?

There doesnt seem to be enough unique information that would be needed to break down the data further into 1st call, 2nd call etc.. or what action was performed. Without this there is no way of knowing whats a first call and whats a subsequent call - its just a list of times in a table with no contextual info

There is more information available, I was just trying to simplify with the example.

The main goal is to charge the client for customers that want to change their enrollment via phone. Since they can change multiple things during one call, I want to use that hour timeframe from the first and last transaction to identify a single call. But a customer could call more then one time a day and speak with the same rep.

I will try the substring, not sure if that will work or how to work it

  • 0

Actually you want to look at the function: DATEPART

Here is the SQL Server info on that function. If you are using Oracle, Sybase, MySQL they have this sort of function too.

http://msdn.microsoft.com/en-us/library/aa...65(SQL.80).aspx

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Microsoft isn't happy you're using unsupported Exchange versions, announces final deadline by Usama Jawad Earlier this month, Microsoft announced Exchange Server Subscription Edition (SE), which is the official transition of the product to the Modern Lifecycle Policy, where software is continuously serviced without an end-of-life date, as long as you keep it updated. It also revealed surprising, but brief, Extended Security Updates (ESUs) for Exchange 2016 and 2019. As it winds down support for these products, the company has expressed some displeasure that some customers are using even older and, obviously, unsupported versions of Exchange. In a blog post, the company has noted that it currently offers migration tools that enable the migration of public folders from on-premise Exchange 2013 or older versions to Exchange Online. This is by design, but Microsoft is now changing its tune on the topic. Starting from October 1, 2025, customers leveraging Exchange 2010 or older versions of the software will not be allowed to use Microsoft's tools to migrate their public folders to Exchange Online. Microsoft believes that this deprecation will reduce reliance on legacy systems and enhance "long-term service reliability". Any migrations that are attempted after the aforementioned date will fail, so Microsoft has urged customers to complete their migrations as soon as possible. If customers want to move their data to Exchange Online after October 1, they will first have to upgrade to a newer Exchange version, which is Exchange 2013, but it is important to keep in mind that supported versions are 2016 and 2019. Microsoft has emphasized in a rather stern tone that it does not encourage using unsupported versions of Exchange Server at all, and it has just put out this advisory because it is aware that public folder migrations from legacy systems are currently active, even though they shouldn't be. Needless to say, customers should upgrade to Exchange Server 2016 or 2019 as quickly as possible, but ideally, they should consider moving to Exchange Server SE at this point, considering that the other two versions are running out of support soon, too.
    • A little bit, yeah, if you ask me. Granted, he has the right to be upset with this jerk user that attacked him, but why drop the entire project just because of ONE person? Seems a little exaggerated.
    • Xbox July Update brings PC app cloud upgrades and Rewards support by Pulasthi Ariyasinghe The Xbox team at Microsoft has another major series of updates hitting its platforms. The Xbox July Update is primarily bringing new features to the PC application, while cloud gaming services are also being upgraded. A lot of these additions were a part of Insider testing sessions previously, but now they are ready for prime time. First off, Game Pass Ultimate members can now stream supported games over the cloud, as long as they own a copy on the Xbox store. The Stream Your Own Game feature can be accessed via the Cloud Gaming section on the Xbox PC app. The feature now boasts over 250 supported games too, with recent additions including classic Assassin's Creed titles, LEGO games, and the Saints Row series. Upcoming games to the lineup include RoboCop: Rogue City – Unfinished Business, Tetris Effect Connected, Wo Long Fallen Dynasty, and more. Check here to get a full list of games. Don't forget that cross-device play histories on the app also landed for Xbox Insiders earlier this month, letting players see what games they have been playing regardless of console, PC, or cloud Xbox platform being used. Another new feature announced today as landing on the PC app this month is Rewards with Xbox. Only available in select markets and only for those above 18, Rewards can now be found in the Home section with easy access to checking out how to get more points, track progress, and more. The Xbox and Antstream Arcade joint venture, the Retro Classics app, is gaining seven more games too. These are Caesar, Conquests of Camelot: The Search for the Grail, Gabriel Knight: Sins of the Fathers, Hard Head, Okie Dokie, Skate Boardin’, and Skeleton+. Lastly, mouse and keyboard as well as touch controls continue to roll out for more games, with Police Simulator: Patrol Officers getting support for the former while South of Midnight has gained the latter.
  • Recent Achievements

    • Week One Done
      NeoWeen earned a badge
      Week One Done
    • One Month Later
      BA the Curmudgeon earned a badge
      One Month Later
    • First Post
      Doreen768 earned a badge
      First Post
    • One Month Later
      James_kobe earned a badge
      One Month Later
    • Week One Done
      James_kobe earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      674
    2. 2
      ATLien_0
      254
    3. 3
      Xenon
      165
    4. 4
      neufuse
      145
    5. 5
      +FloatingFatMan
      117
  • Tell a friend

    Love Neowin? Tell a friend!