select MAX(别名) from ( select COUNT(付款方式) 别名from 表名 group by 付款方式 ) t
表时需要一个字段,表示被选择的次数。select top 前多少个最常用的 ... from ....... order by .. 降序
select MAX(列名) as '付款方式' from 表名 group by 列名
to:soaringbird 你这个得出的是重复数量,我要的是重复数量最多的原记录的值
这样是否正确?select top 1 ReceiveMethodID from ( select ReceiveMethodID,COUNT(ReceiveMethodID)b from transportOrders group by ReceiveMethodID )t order by b desc
抱歉,看错了。既然是想得到那个值,就不用子查询了。 select top 1 ReceiveMethodID,COUNT(ReceiveMethodID) b from transportOrders group by ReceiveMethodID order by b desc
楼上的都解决了 select top 1 count(字段名) '别名' from 表名 group by 字段名 order by 别名 desc
select top 1 orderid ,count(付款方式) as num from t1 group by orderid order by num desc
(
select COUNT(付款方式) 别名from 表名
group by 付款方式
) t
你这个得出的是重复数量,我要的是重复数量最多的原记录的值
(
select ReceiveMethodID,COUNT(ReceiveMethodID)b from transportOrders group by ReceiveMethodID
)t order by b desc
select top 1 ReceiveMethodID,COUNT(ReceiveMethodID) b from transportOrders
group by ReceiveMethodID
order by b desc
select top 1 count(字段名) '别名' from 表名
group by 字段名
order by 别名 desc