我有一张桌子,我希望每周从桌子上检索信息,这意味着一周内预订了多少个摊位
SELECT `sold_by` , COUNT(`booth_number` ) , `Date` FROM `registration`
WHERE `Date` BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()
GROUP BY `sold_by` ";
//$result="SELECT count(`booth_number`),`sold_by`
FROM `registration` GROUP BY `sold_by` ";
答案 0 :(得分:0)
这是你在找什么?
SELECT sold_by, YEARWEEK(Date), COUNT(booth_number) FROM registration GROUP BY sold_by, YEARWEEK(Date)