I have a list of customers on a waiting list for services to be rendered today. I want to calculate on average how long it takes from the time the customer was queued to the time that customer record was updated. I'm not really sure of the correct table structure to achieve this, but I'm guessing the structure below would be fine.

So essentially, I want to be able to display to waiting customers on average, the time it takes for service to be rendered --obviously, the average time would be dynamic as some customers would be attended to faster than others.

1   queue_num   int(11)
2   clientID    varchar(12)
3   customerid  varchar(15)
4   todays_date datetime
5   updated datetime
6   request varchar(255)
7   details text
8   status  varchar(15)

Any thoughts on how this can be done!

Thanks!
Mossa

I assume, it would be something like this?

Average wait = (time service is provided) minus (time listed on the waiting list )

Thank you veedeoo; I've constructed something like

SELECT AVG(UNIX_TIMESTAMP(updated) - UNIX_TIMESTAMP(todays_date)) as avgTime FROM queue_sys WHERE updated != '0000-00-00 00:00:00'

At the moment, it seems to be working, but if there is anything you see that can be modified, please advise...

Mossa

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.