select `a`.`tdorderid`,group_concat('类型:',(case `a`.`td_type` when 'no_goods' then '无货退款' when 'low_quantity' then '质量退款'
when 'no_reason' then '非质量退款' else '无' end),'/退货员:',(case when`a`.`td_user` is null then '无'
when `a`.`td_user` is not null then `a`.`td_user` end) separator ',') AS `goods1` from `gr_reject_goods` `a` group by `a`.`tdorderid`
在group_concat函数里面使用case when 语法与一般情况无异。
case when 在判断是否为null的时候要注意,字段 is null ,字段is not null
本文介绍了一种结合使用 SQL 中 Case When 语句与 Group Concat 函数的方法,通过具体示例展示了如何根据不同的条件组合数据并进行分组汇总,适用于需要将多个字段的数据按指定格式合并成单一字符串的应用场景。
2776

被折叠的 条评论
为什么被折叠?



