Mysql GROUP_CONCAT函数多个字段合并的使用
2022/7/21 2:54:37
本文主要是介绍Mysql GROUP_CONCAT函数多个字段合并的使用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
select a.xcbh '现场编号',a.xz '被征收人' ,thz_fzmj '土地有证',round(thz_tdmj-thz_fzmj,2) '土地无证',thz_tdmj '土地合计(㎡)',i.房屋框架,i.房屋混合,i.房屋砖木,i.房屋面积合计㎡,t.主要附属物合计㎡_m³,g.其他附属物及青苗 from x as a left join typg_house_zd as z on z.thz_xcbh=a.xcbh left join typg_house as h on h.th_xcbh=a.xcbh left join (select thi_xcbh, round(sum(case when thi_fwjg='框架结构' then thi_buildmj else 0 end),2) '房屋框架', round(sum(case when thi_fwjg='混合结构' then thi_buildmj else 0 end),2) '房屋混合', round(sum(case when thi_fwjg='砖木结构' then thi_buildmj else 0 end),2) '房屋砖木', round(sum( thi_buildmj ),2) '房屋面积合计㎡' from typg_house_info where del_flag=0 group by thi_xcbh ) i on i.thi_xcbh=a.xcbh left join (select tht_xcbh, round(sum( tht_num ),2) '主要附属物合计㎡_m³' from typg_house_tag where del_flag=0 and (tht_unit='m' or tht_unit='㎡' or tht_unit='m²' or tht_unit='m³') group by tht_xcbh ) t on t.tht_xcbh=a.xcbh left join (select tht_xcbh,GROUP_CONCAT(tht_fswmc,'',round(tht_num,0),'',tht_unit separator '|') as 其他附属物及青苗 from (select * FROM typg_house_tag where del_flag=0 and tht_unit<>'m' and tht_unit<>'㎡' and tht_unit<>'m²' and tht_unit<>'m³') f GROUP BY tht_xcbh ) g on g.tht_xcbh=a.xcbh where a.xcbh is not null
GROUP_CONCAT(tht_fswmc,'',round(tht_num,0),'',tht_unit separator '|') as ’字段‘
这篇关于Mysql GROUP_CONCAT函数多个字段合并的使用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-04-26MySQL查出时间比实际晚8小时的解决方案
- 2024-04-01JPA不识别MySQL的枚举类型
- 2024-03-30mysql数据库表卡死解决方法
- 2024-03-15MySQL多数据源笔记5-ShardingJDBC实战
- 2024-03-11natural join mysql
- 2024-03-11关于VS2017,VS2015 中利用 EF使用Mysql 不显示数据源问题解决方案
- 2024-02-26mysql 阿里云xb后缀备份文件恢复-icode9专业技术文章分享
- 2024-02-22docker mysql 5.7
- 2024-02-18从 20 多套 MySQL 到 1 套 TiDB丨骏伯网络综合运营管理平台应用实践
- 2024-02-07mysql 外键索引入门介绍,为什么工作中很少有人使用?