在MYSQL中比较两周之间的数据

时间:2019-06-13 10:27:45

标签: mysql

我正在尝试比较本周和上周之间的数据

以下是我的查询:

select  ifnull(name,'DGG') as name,ifnull(mobile,'DGG') as mobile,year(date) as Year,
monthname(date) as Month,animalid as AnimalID,milkmor,milkeve,
 milkmor+milkeve/ 2 as avgmilk
from table 
where  date < curdate() - INTERVAL DAYOFWEEK(date())+6 and DAYOFWEEK(curdate())-14 DAY
group by animalid
order by ifnull(name,'DGG') asc;

我希望能够将本周的记录与上周的记录进行比较,并计算两周之间的标准偏差,均值,最小和最大牛奶量

0 个答案:

没有答案