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
https://forums.phpfreaks.com/topic/108545-math-not-adding-up/
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
https://forums.phpfreaks.com/topic/108545-math-not-adding-up/#findComment-557619
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.