如何得出列中那个字段对多
- SQL code
create table table1(a varchar(2));insert into table1 select 'h'insert into table1 select 'a'insert into table1 select 'b'insert into table1 select 'b'insert into table1 select 'c'insert into table1 select 'c'insert into table1 select 'a'insert into table1 select 'd'insert into table1 select 'd'insert into table1 select 'd'insert into table1 select 'a'.....select a from table1;drop table table1;
如何得出列中那个字段对多
[解决办法]
[解决办法]
- SQL code
select *,count(*) as total from table1 group by ahaving count(*)=(select max(total) from(select *,count(a) as total from table1 group by a)t)--a,d一样多-----------a total---- -----------a 3d 3