日期:2014-05-16 浏览次数:20897 次
select sum(c) from tbl where A='m';
------解决方案--------------------
select * from tb1 where c in(select c from tb1 group by c having count(1)>1);
------解决方案--------------------
create table tb1 ( a char(1), b char(3), c int ); insert tb1 select 'm', '3-1', 34 union select 'f', '3-1', 29 union select 'm', '3-2', 33 union select 'f', '3-2', 30 union select 'm', '3-3', 33; create table tbss ( b char(3), count_boy int ); insert tbss select b,sum(c) as count_boy from tb1 where a='m' group by b; select s.b from tbss s join( SELECT count_boy from tbss group by count_boy having count(*)>1) z on s.count_boy=z.count_boy /* 3-2 3-3 */