Select Count(*) From (select stor_id from sales where ..group by stor_id having count(*)>1 ) aa
select stor_id,count(*) from table group by stor_id having count(*) > 1 order by 1
select stor_id from sales group by stor_id having count(*)> 1 结果为:stor_id 6380 7066 7067 7131 7896 8042 而我要的结果是6,即上述结果的合计数,:warning(爱就爱了) ,:N_chow(一劍飄香++),:Eric2000(Eric2000的方法我发现都不能得到该结果。
Select Count(*) From (select stor_id from sales group by stor_id having count(*)> 1 ) aa 不對嗎
N_chow(一劍飄香++) 的应该正确!是不是有空值?试试下面的: Select Count(*) From (select stor_id from sales group by stor_id having count(stor_id)>1) aa
:N_chow(一劍飄香++)正确!谢谢了,给分!!!
Select Count(*) From (select distinct stor_id from sales group by stor_id having count(*)> 1 ) aa
(select stor_id from sales where ..group by stor_id having count(*)>1 )
aa
group by stor_id
having count(*) > 1
order by 1
group by stor_id
having count(*)> 1
结果为:stor_id
6380
7066
7067
7131
7896
8042
而我要的结果是6,即上述结果的合计数,:warning(爱就爱了) ,:N_chow(一劍飄香++),:Eric2000(Eric2000的方法我发现都不能得到该结果。
(select stor_id from sales
group by stor_id
having count(*)> 1 )
aa
不對嗎
Select Count(*) From (select stor_id from sales
group by stor_id
having count(stor_id)>1) aa
(select distinct stor_id from sales
group by stor_id
having count(*)> 1 )
aa
http://www.csdn.net/expert/topic/562/562999.xml