Jump to content

Math not adding up


tobeyt23

Recommended Posts

trying to calculate total minutes used correctly, obviously if you add the totals the for the minutes it is incorrect what am i doing incorrect?

 


(
SELECT IF( voip_log.direct_dial = 'true', 'Direct Dial', IF( voip_log.voiceblast =1, 'Voice Broadcast', 'PhoneLink' ) ) Call_Type, count( voip_log.id ) Total_Calls, CEIL( SUM( unix_timestamp( STR_TO_DATE( callendtime, '%m/%d/%Y %r' ) ) - unix_timestamp( STR_TO_DATE( callconnecttime, '%m/%d/%Y %r' ) ) ) /60 ) Total_Minutes_Used
FROM icar.voip_log, icar.dealer
WHERE voip_log.dealerID = dealer.id
AND voip_log.callendtime >0
AND voip_log.status = 'complete'
AND voip_log.timestamp
BETWEEN '1207022400'
AND '1209614399'
GROUP BY Call_Type
)
UNION ALL (

SELECT 'Total'Call_Type, count( voip_log.id ) Total_Calls, CEIL( SUM( unix_timestamp( STR_TO_DATE( callendtime, '%m/%d/%Y %r' ) ) - unix_timestamp( STR_TO_DATE( callconnecttime, '%m/%d/%Y %r' ) ) ) /60 ) Total_Minutes_Used
FROM icar.voip_log, icar.dealer
WHERE voip_log.dealerID = dealer.id
AND voip_log.callendtime >0
AND voip_log.status = 'complete'
AND voip_log.timestamp
BETWEEN '1207022400'
AND '1209614399'
GROUP BY Call_Type
) 

 

this is what is returned:

Call_Type            Total_Calls            Total_Minutes_Used

Direct Dial        24045                51814

PhoneLink     1                       1

Voice Broadcast  24                     14

Total               24070               51828

Link to comment
Share on other sites

First select:

 

Call_Type Total_Calls Total_Minutes_Used

Direct Dial 24045 51814

PhoneLink 1 1

Voice Broadcast 24 14

 

Second select:

Call_Type Total_Calls Total_Minutes_Used

Total 24070 51828

 

Orginal:

 

Call_Type Total_Calls Total_Minutes_Used

Direct Dial 24045 51814

PhoneLink 1 1

Voice Broadcast 24 14

Total 24070 51828

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.