CDR statistics(Wait Time, Hold Time, TAlk Time and Ring Time

Hello,

Could you please let me know, how I can calculated the following metrics for a call based on cdrs and queue_events?
a. Wait Time
b. Hold time
c. Talk Time
d. Ring Time

Thanks in advance !!