-_id -lesson_id -start_time -SUMDUEDURATION -COUNTDUEDURATION -INTERVAL
-105 -1 -2013-10-16 07:26:52.000 -92736 -9 -301418
-108 -1 -2013-10-18 07:03:52.000 -164282 -3 -555779
-116 -1 -2013-10-21 11:49:44.000 -1455866-7 -3533900
-128 -1 -2013-10-22 11:12:55.000 -53795 -12 -108334
-132 -1 -2013-10-30 03:27:46.000 -2036 -1 -663295276
这是用户操作表中的记录,一个月中只有几天,有没有像 MySQL 这样的事件时间表自动插入其他日期。
我用它来跨越一个日期表,但还不够好:
select _id,lesson_id,start_time, ifnull(sum,0) as SUMDUEDURATION, ifnull(COUNT,0) as COUNTDUEDURATION, ifnull(interval, 0) as INTERVAL
from dates left join (
SELECT month,_id, lesson_id, sum(duration) as sum,count(_id) as count,interval,
start_time,end_time,
max(date(" + START_TIME + ", 'weekday 0', '-7 day')) as WeekStart,
max(date(" + START_TIME + ", 'weekday 0', '-1 day')) as WeekEnd
FROM user_action where lesson_id = 1 group by month ) monthdate using(month)
where strftime('%Y%m',date) = strftime('%Y%m','now')