简体   繁体   中英

Sql average time calculation

I'm trying to write a sql query that gives me the average time.

I have 5 columns and multiple entries.

the five columns are taxi-number start-date end-date start-time end-time.

I need to find the average time, times given are in 24 hour format but I also need to account for the difference in start-date and end-date if its there,and i need to group it by taxi number. input

Taxi-Number Start-Date  Start-Time  End-Date    End-Time
4412    8/8/2015    18:06:00    8/9/2015    14:00:00
2223    4/18/2013   19:33:00    4/19/2013   0:40:00
1112    10/20/2013  11:23:00    10/22/2013  8:33:00
5553    5/18/2015   21:43:00    5/19/2015   9:15:00
2222    4/9/2014    0:00:00 4/10/2014   0:16:00

output

taxi 4412, average time 20 hours 6 minutes or in any format that accounts for this

Thanks.

Not an answer. Too long for a comment...

Start here:

Taxi_Number Start_Date          End_Date    
4412        2015-08-08 18:06:00 2015-08-09 14:00:00

Once you have that as your structure, see Why should I provide an MCVE for what seems to me to be a very simple SQL query? ... and then get back to us.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM