明天的明天 永远的永远 未知的一切 我与你一起承担 ??

是非成败转头空 青山依旧在 几度夕阳红 。。。
随笔 - 1277, 文章 - 0, 评论 - 214, 阅读 - 320万
  博客园  :: 首页  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

Mysql GROUP_CONCAT函数多个字段合并的使用

Posted on   且行且思  阅读(1316)  评论(0编辑  收藏  举报
复制代码
 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='' or tht_unit='') 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<>'' and tht_unit<>'') 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 ’字段‘

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
历史上的今天:
2020-07-20 SpringBoot启动后自动打开浏览器访问项目
2018-07-20 Jquery 样式选择器,查找包含两种样式以上的元素
点击右上角即可分享
微信分享提示