返回MySQL的总小时数

时间:2014-06-27 18:50:50

标签: mysqli sum totals

如何将总小时数作为总计返回?

SELECT `phpc_events`.`eid`, `phpc_occurrences`.`eid`, `phpc_events`.`uid`,  TIMESTAMPDIFF(HOUR,`phpc_occurrences`.`start_ts`,`phpc_occurrences`.`end_ts`) as hours, SUM(hours) as total
FROM `phpc_events` 
LEFT JOIN `phpc_occurrences` 
ON `phpc_events`.`eid` = `phpc_occurrences`.`eid`
WHERE `phpc_events`.`catid`="3" &&
`phpc_events`.`uid`="1"
ORDER BY `phpc_occurrences`.`start_ts`

0 个答案:

没有答案