MySQL如何求出相同值的数据

1.png

如图所示  如何求出 数据 3,1的值

勇敢的打工人 发布于 2022-6-28 19:15
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
勇敢的打工人Lv4见习互助
发布于2022-9-20 09:32

用的开窗函数处理的

最佳回答
0
好好生活好好学习Lv7资深互助
发布于2022-6-28 19:35

直接分组求条数

select  id,count(*) as con from  表 group by id

con大于1的就是有相同值的数据

最佳回答
0
CD20160914Lv8专家互助
发布于2022-6-28 20:21

select tmp.card_no,tmp.pay_amount,count(tmp.pay_amount) as 个数 from (

select '88882560020000000221' as card_no,4 as pay_amount union all

select '88882560020000000221' as card_no,3 as pay_amount union all

select '88882560020000000221' as card_no,3 as pay_amount union all

select '88882560020000000221' as card_no,1 as pay_amount union all

select '88882560020000000221' as card_no,0.7 as pay_amount union all

select '88882560020000000221' as card_no,1.5 as pay_amount union all

select '88882560020000000221' as card_no,1.2 as pay_amount union all

select '88882560020000000221' as card_no,1 as pay_amount union all

select '88882560020000000221' as card_no,1 as pay_amount union all

select '88882560020000000221' as card_no,2 as pay_amount union all

select '88882560020000000221' as card_no,8 as pay_amount union all

select '88882560020000000221' as card_no,9 as pay_amount union all

select '88882560020000000221' as card_no,6 as pay_amount union all

select '88882560020000000221' as card_no,3.33 as pay_amount

) tmp

group by card_no,pay_amount

having count(tmp.pay_amount)>1

image.png

  • 2关注人数
  • 406浏览人数
  • 最后回答于:2022-9-20 09:32
    请选择关闭问题的原因
    确定 取消
    返回顶部