Avg function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Avg function

[b][red]This message was edited by wannabedba at 2005-1-19 8:4:52[/red][/b][hr]
how can i take the difference of 2 date/time (in minutes)columns and get the average? i have orders received time and orders completed time for every order in every state over a period of one month. my select statement is below, but for some reason it is returning some negative values. oh and one more thing, i need to not include saturdays and sundays 12/3,4,10,11,17,18,24,25,31. any input would be greatly appreciated.

select rt_state.state_code, avg(datediff(mi,dt_orders.request_received_date,dt_orders.order_delivered_date))
from dt_orders, dt_address, rt_state
where dt_orders.address_id = dt_address.address_id and
dt_address.state_number = rt_state.state_number and
dt_orders.request_received_date between '12/1/04' and '1/1/05' and
dt_orders.order_delivered_date < '1/1/05'
group by rt_state.state_code;

Sign In or Register to comment.