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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:53:27+00:00 2026-05-28T01:53:27+00:00

I have a table from our IVR that contains a unique call id, sequence

  • 0

I have a table from our IVR that contains a unique call id, sequence number, event code, and event description. I would like to write a query that let’s me know what was the event prior to a particular event.

  • 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-05-28T01:53:27+00:00Added an answer on May 28, 2026 at 1:53 am

    Depending on what indexes exist on the table, a straightforward inner join may receive a better-performing access plan from the query optimizer.

    SELECT n.call_id, 
        n.event_dt, 
        n.sequence_number, 
        p.call_id as prior_call_id, 
        p.event_id as prior_event_id,
        p.event_dt as prior_event_dt,
        p.sequence_number as prior_sequence_number
    FROM daily_events n
    INNER JOIN daily_events p
        ON p.sequence_number = n.sequence_number - 1
    WHERE n.event_id = '5047'
    AND n.event_dt >= DATE( '01/06/2012' ) 
    AND n.event_dt <= DATE( '01/07/2012' );
    

    The query assumes that any event with a sequence number that differs by one is an appropriate match, and that the call_id doesn’t also need to match. If that assumption is incorrect,
    then add AND n.call_id = p.call_id to the ON clause of the join.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table that I insert data with following query (from c# code): INSERT
We have a SQL table that is populated with events from our website (mostly
I have a table that contains some sensitive data that I would like to
I have an application that reads a table from a database. I issue an
I'm writing a stored procedure that should sync a table from our production environment
I have a table that contains a list of machines that are loaned out
I have a weekly script that moves data from our live database and puts
We have a db dump import script from our production db that we use
I have an Excel spreadsheet that needs to display data from our SQL database.
Okay, so we have a utility here in-house that generates business-model classes from our

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.