ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

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

2022-07-20 10:31:15  阅读:186  来源: 互联网

标签:GROUP xcbh house tht CONCAT thi Mysql round unit


 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 ’字段‘

标签:GROUP,xcbh,house,tht,CONCAT,thi,Mysql,round,unit
来源: https://www.cnblogs.com/Fooo/p/16496921.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有