sql - Calculate average time difference between two datetime fields per day -


I have a taxi database, in which the two-day time field is 'Booked Time' and 'Pickupdate Time'. The customer will have to know the average wait time from the time the taxi was booked from that time when the driver actually 'picked up' the customer

Rows in the database covering data of a few months There is a heap.

The goal is prepared according to a daily question which shows me daily average.

> Then a super simple example would be:

  BookedDateTime | PickupDateTime 2014-06-09 12: 48: 00.000 2014-06-09 12: 45: 00.000 2014-06-09 12:52 52: 00.000 2014-06-09 12:58 58: 00.000 2014-06-10 20:23: 00.000 2014-06-10 20: 28: 00.000 2014-06-10 22: 13: 00.000 2014-06-10 22: 13: 00.000  

2014-06-09 ((- 3 + 6) / 2) Avg = 00: 03: 00.000 (3 minutes)

2014-06-10 ((5 + 0) / 2) = Average is 00: 02: 30.000 (mins 2.5 )

Is it possible or do I need to do some crunching in code (i.e. C #)?

Any hints would be appreciated.

I think this would be:

  date, of bookdeterm Select Date, AVG (dated)  
Convert (date, bookdetermine) as the average time (date, book date, pickupdate) by Convert (date, bookdetermine)

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -