group by 分组,取第一个就行了(top 1 with ties)好像就可以了,但是你说的是随机选一个,这个有什么意义啊。
with cte as( select row_number() over(partition by [客户编码] order by [数量] desc) cnt ,* from [表A] ) select * from cte where cnt=1
没太看懂问题。
34,837
社区成员
254,632
社区内容
加载中
试试用AI创作助手写篇文章吧