Skip to content
Advertisement

How to find the average time? SQL Server 2017

I have a request like this:

enter image description here

I need to find the average time for each status. For example, add up the time of all statuses 2 and divide by their number. As a result, get something like 2 days 5 hours.

How to fix my request to make belt operations possible?

enter image description here

enter image description here

Advertisement

Answer

Taking your limited example data, something like this does the job, although it’s not pretty:

You get these results:

Results

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement