我想带两个最大的数字和数量。
如何为图片编写代码?
需要根据第二种方式编写代码。
从SatisBaslik sbb group中选择sbb.musteriId,count(1) sbb.musteriId有count(1)=(从中选择x.adet(select count(1) 来自SatisBaslik sb group by sb.musteriId 算(1)
"(从(选择count(1)adet中选择x.adet来自SatisBaslik sb group 由sb.musteriId计数(1)
答案 0 :(得分:0)
尝试此查询:
select musteriId, count(musteriId) from SatisBasligi where musteriId in (7, 8, 9);
答案 1 :(得分:0)
使用Group By
和Having
子句
select musteriId, count(musteriId)
from SatisBasligi
Group by musteriId
Having count(musteriId) > 1
答案 2 :(得分:0)
对于mysql:
select musteriId, count(*)
from SatisBasligi
group by musteriId
having count(musteriId) > 1
答案 3 :(得分:0)
为了获得最大的两个计数,请将ORDER BY
与TOP
一起使用并添加WITH TIES
,以便获得具有相同计数的集合。
select top(2) with ties
musteriId,
count(*)
from SatisBasligi
group by musteriId
order by count(*) desc;