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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:53:15+00:00 2026-06-17T09:53:15+00:00

I would really appreciate some assistance if somebody could help me construct a MSSQL

  • 0

I would really appreciate some assistance if somebody could help me construct a MSSQL Server 2000 query that would return the duration between a customer’s A entry and their B entry.

Not all customers are expected to have a B record and so no results would be returned.

Customers Audit

+---+---------------+---+----------------------+
| 1 | Peter Griffin | A | 2013-01-01  15:00:00 |
| 2 | Martin Biggs  | A | 2013-01-02  15:00:00 |
| 3 | Peter Griffin | C | 2013-01-05  09:00:00 |
| 4 | Super Mario   | A | 2013-01-01  15:00:00 |
| 5 | Martin Biggs  | B | 2013-01-03  18:00:00 |
+---+---------------+---+----------------------+

I’m hoping for results similar to:

+--------------+----------------+
| Martin Biggs | 1 day, 3 hours |
+--------------+----------------+
  • 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-17T09:53:16+00:00Added an answer on June 17, 2026 at 9:53 am

    Something like the below (don’t know your schema, so you’ll need to change names of objects) should suffice.

    SELECT ABS(DATEDIFF(HOUR, CA.TheDate, CB.TheDate)) AS HoursBetween
    FROM dbo.Customers CA
    INNER JOIN dbo.Customers CB
    ON CB.Name = CA.Name
    AND CB.Code = 'B'
    WHERE CA.Code = 'A'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am bit stuck with this MSSQL query and would really appreciate some help
I would really appreciate it if some of you could help optimize my tables,
I'm fairly new to SQL Server and would really appreciate some help with this.
Hi I would really appreciate some help in forming a regex that removes a
Would really appreciate some help with a search angine I'm trying to make for
I would really appreciate some help with my problem: I have 2 MySQL tables,
I would really appreciate some help on this. I have relationships such as: class
I am new to Ruby and would really appreciate some help understanding what is
I'm new to Android developing and I would really appreciate some help here. I'm
I'm totally stumped on this error. Would really appreciate some help :). To reproduce

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.