首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

group by条件有关问题

2012-02-24 
group by条件问题select count(materialprofile.F_SN) as qty,F_SNfrom tempwhereF_closetime BETWEEN 20

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 tempwhere  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 tempwhere 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 tempwhere  F_closetime BETWEEN '2010-06-01' AND '2011-01-01'group by F_SNhaving count(*)>2
[解决办法]
SQL code
select count(materialprofile.F_SN) as qty,F_SN from tempwhere  F_closetime BETWEEN '2010-06-01' AND '2011-01-01'  group by F_SN having count(1)>2 

热点排行
Bad Request.