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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:25:19+00:00 2026-06-18T09:25:19+00:00

I am trying to create a query to provide me with the turnaround time

  • 0

I am trying to create a query to provide me with the turnaround time in minutes of a number of rows of testing data.

A succinct version of the table is:

TestName, StartDateTime, EndDateTime

And I am looking for a query that can give me a output something like:

Distinct TestName 
, StartDate[not time]
, Count(rows) as Total
, Count(rows where datediff(minute, StartDateTime, EndDateTime) <=60) as NonBreach
, Count(rows where datediff(minute, StartDateTime, EndDateTime) >60) as Breach
, Count(rows where datediff(minute, StartDateTime, EndDateTime) >60) / Count(rows) as BreachRate

Is this principle even possible?

Any direction would be greatly appreciated.

  • 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-18T09:25:20+00:00Added an answer on June 18, 2026 at 9:25 am

    You could use something like this:

    SELECT  TestName,
            CAST(StartdateTime AS DATE) AS StartDate,
            COUNT(*) AS Total,
            COUNT(CASE WHEN DATEDIFF(MINUTE, StartDateTime, EndDateTime) <= 60 THEN 1 END) AS NonBreach,
            COUNT(CASE WHEN DATEDIFF(MINUTE, StartDateTime, EndDateTime) > 60 THEN 1 END) AS Breach,
            1.0 * COUNT(CASE WHEN DATEDIFF(MINUTE, StartDateTime, EndDateTime) > 60 THEN 1 END) / COUNT(1) AS BreachRate
    FROM    YourTable
    GROUP BY TestName, CAST(StartdateTime AS DATE)
    

    Although depending on your DBMS you may need to use a different method of removing the time from the date.


    Removing time from date:


    SQL-Server 2008 and later:

    SELECT  CAST(CURRENT_TIMESTAMP AS DATE)
    

    SQL-Server 2005 and Earlier

    SELECT  DATEADD(DAY, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP), 0)
    

    MySQL & SQLite

    SELECT  DATE(CURRENT_TIMESTAMP)
    

    Oracle

    SELECT  TRUNC(CURRENT_TIMESTAMP)
    

    Postgresql

    SELECT  CURRENT_TIMESTAMP::DATE
    

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

Sidebar

Related Questions

I'm trying to create an SQL query in PHP to update a table. Is
We are trying to create/query information from a CF based on the following structure
i am trying to create a query on my simpleDB. here is the query:
I'm trying to create wmi query to sccm to get PC, where was user's
I'm trying to create a query with the Criteria API from JPA 2.0, but
I trying to create a MySql Query from the $_POST values trouble is i
I'm trying to create a faster query, right now i have large databases. My
Im trying to create a select command to query the database I have and
I'm trying to create a custom SELECT query to find my Personal Best races
I'm basically trying to create a url friendly query string with user input. The

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.