'WHERE'子句中的MySql'min'

时间:2012-03-07 22:07:27

标签: mysql where

我有这个查询

select date(fecha) as day, min(num) as mi  
from myTable 
where date(fecha) >= date(now()) 
group by day;

我如何在mi < 10类似于

的地方添加此条件
select date(fecha) as day, min(num) as mi  
from myTable 
where date(fecha) >= date(now()) 
and mi < 10 
group by day;

2 个答案:

答案 0 :(得分:7)

使用“拥有”声明

select date(fecha) as day, min(num) as mi  
from myTable where date(fecha) >= date(now()) 
group by day
having min(num) < 10;

答案 1 :(得分:0)

也许这......

select date(fecha) as day, min(num) as mi  
from myTable 
where date(fecha) >= date(now()) 
and num < 10 
group by day;