首页 服务 产品 文档 关于

sqlserver 按某列值的重复次数排序

表格article按标题重复次数降序列表查询,返回title和title值的重复次数:

status=1条件为article的列status

select top 3 tb1.* from (select title,count(*) as count from article where status=1 group by title) as tb1 order by tb1.count desc