日期:2014-05-18  浏览次数:20625 次

group by条件问题
select count(materialprofile.F_SN) as qty,F_SN 
from temp
where 
F_closetime BETWEEN '2010-06-01' AND '2011-01-01' 

想加个条件是qty > 2 的显示
这个条件怎么写呀


------解决方案--------------------
SQL code
select count(materialprofile.F_SN) as qty,F_SN  
from temp
where  
F_closetime BETWEEN '2010-06-01' AND '2011-01-01'  
group by F_SN having count(materialprofile.F_SN)>2

------解决方案--------------------
SQL code
select count(materialprofile.F_SN) as qty,F_SN 
from temp
where 
F_closetime BETWEEN '2010-06-01' AND '2011-01-01'  
group by F_SN 
having count(materialprofile.F_SN)>2

------解决方案--------------------
SQL code
select count(*) as qty,F_SN  
from temp
where  
F_closetime BETWEEN '2010-06-01' AND '2011-01-01'
group by F_SN
having count(*)>2

------解决方案--------------------
SQL code
select
 count(materialprofile.F_SN) as qty,F_SN 
from
 temp
where 
 F_closetime BETWEEN '2010-06-01' AND '2011-01-01'  
group by
 F_SN 
having
 count(1)>2