mysql “group by“的字段与“select“的字段不一致不报错!

select DEPT_CODE, GRADE, PARENT_ID from ${tableName} where tenant_id = :tenantId and 
customer_id in (:customerIds) and type in (identityTypes) group by DEPT_CODE,GRADE

一般来说查询的字段要和group by的字段一致,但是mysql做了特殊处理,实际上执行的是

select DEPT_CODE, GRADE, any_value(PARENT_ID) from customer_identity where tenant_id = '10023' and customer_id in (989633593863100416) and type in ("c_dmhub_userid") group by DEPT_CODE, GRADE

any_value()会选择被分到同一组的数据里第一条数据的指定列值作为返回数据,特此记录

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值