每周销售报告摘要mysql php

时间:2013-09-10 07:07:24

标签: php mysql

我有一张桌子,我希望每周从桌子上检索信息,这意味着一周内预订了多少个摊位

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`  ";

1 个答案:

答案 0 :(得分:0)

这是你在找什么?

SELECT sold_by, YEARWEEK(Date), COUNT(booth_number) FROM registration GROUP BY sold_by, YEARWEEK(Date)

在此处测试http://sqlfiddle.com/#!2/ae782/1