我有一个property_viewers
包含 3 个字段的表格;id、property_id、日期。我需要找到上周重复的最大 property_id。我该如何进行...
问问题
144 次
3 回答
1
尝试这个:
select *, count(1) from property_viewers where DATEDIFF(date, DATE(now()))<8 group by property_id order by count(1) desc
于 2012-07-11T08:08:50.633 回答
0
SELECT property_id
FROM property_viewers
WHERE date BETWEEN
CURRENT_DATE() - INTERVAL (7+WEEKDAY(CURRENT_DATE())) DAY AND //Monday last week
CURRENT_DATE() - INTERVAL (1+WEEKDAY(CURRENT_DATE())) DAY //Sunday last week
GROUP BY property_id
ORDER BY COUNT(property_id) DESC
于 2012-07-11T08:21:16.040 回答
0
select property_id, count(property_id) from property_viewers
where `date` between 'weekSTartDate' and 'weekEndDate'
group by property_id order by count(property_id) desc;
于 2012-07-11T08:18:32.073 回答