我有以下2查詢的,但他們返回不同的結果。例如,如果我要求從一個終端總量獲得:456Mysql的組由15分鐘不匹配總額
如果我再問問它在15分鐘的間隔,算上所有的值的了,我得到474 ......這怎麼可能?
我的查詢,以獲取總量以下
SELECT SUM(logs.amount) * ei_relationships.itemprice as income
, currency
FROM ei_relationships
RIGHT OUTER JOIN logs ON ei_relationships.id = logs.ei_relationship_id
WHERE ei_relationships.event_id = 1
AND logs.serial = '5B:13:52:28:71:21:ED:F1'
ORDER BY currency, log_time ASC
這是我的查詢,以獲得相同的數據,但現在在15分鐘把它
SELECT SUM(logs.amount) * ei_relationships.itemprice as income
, UNIX_TIMESTAMP(log_time) - UNIX_TIMESTAMP(log_time)%(900) as hour
, currency
FROM ei_relationships
RIGHT OUTER JOIN logs ON ei_relationships.id = logs.ei_relationship_id
WHERE ei_relationships.event_id = 1
AND logs.serial = '5B:13:52:28:71:21:ED:F1'
GROUP BY hour
ORDER BY currency, log_time ASC