我有一个名为ch6
的表,它有这样的字段:
id, daytime, tout, tloss.. etc.
daytime is DATETIME , tout and tloss are integer
现在,我想检索并列出表中每个日期的tloss
和tout
的总和,如下所示
date || sum(tout) for certain interval || sum(tloss) for certain interval
我遇到了一些问题,间隔到第二天
前任:
20-2-2014 || (sum of tout from 8:00pm to 8:00am the next day) || (sum of tloss between 8:00pm to 8:00am the next day)
解决方案是什么?请帮忙。
你可以
像下面这样尝试
SELECT daytime , SUM(tout) AS total_tout , SUM(tloss) as total_loss
FROM ch6
WHERE daytime
BETWEEN CURRENT_DATE() + INTERVAL 20 HOUR AND CURRENT_DATE() + INTERVAL 32 HOUR
GROUP BY daytime;