表结构如下图,找出productid 列中出现次数最多的productid ,

查询产品报价表中商家报价最多的产品id

 

语句为:select  top 1 count( productid) as mycount,productid from dbo.CatalogsProducts group by productid order by mycount desc

如果要找出出现次数大于7的;

应该为:select top 10  count( productid) as mycount,productid from dbo.CatalogsProducts group by productid having  count( productid)>7 order by mycount desc

注意:这个的count( productid)>7不能换为mycount>7,要报“列名 'mycount' 无效”的错误。

相关文章:

  • 2021-12-05
  • 2021-09-06
  • 2021-12-10
  • 2022-01-14
  • 2021-12-19
  • 2021-10-10
  • 2022-12-23
猜你喜欢
  • 2022-01-26
  • 2022-01-29
  • 2021-10-11
  • 2022-12-23
  • 2021-10-16
  • 2022-01-16
  • 2021-06-09
相关资源
相似解决方案