<!-- 对发送方式合并查询 -->
<!--查询所有满足条件的营销活动 -->
<select id="CRM-MK-ACT-DEFINE-SELECT" resultMap="RM-MK-ACT-DEFINE-INFO">
select mad.msg_def_name ,mad.msg_def_type,mad.msg_def_content,mad.id,
mad.act_start_date,mad.act_end_date,mad.remark,mad.created_user,masw.NAME from
mk_act_define mad LEFT JOIN (select *,group_concat(case when sent_way_value = ‘SMS‘ then ‘短信‘ when sent_way_value = ‘Mail‘ then ‘邮件‘ end SEPARATOR ‘;‘) as NAME
from mk_act_sent_way group by msg_def_id) masw on (mad.id=masw.msg_def_id)
where mad.`status`=‘1‘
<!-- <![CDATA[ and msg_def_type <> ‘BIRTHDAY‘]]> -->
<dynamic>
<isNotEmpty property="mkactdefine.id" prepend=" and ">
mad.id=#mkactdefine.id#
</isNotEmpty>
<isNotEmpty property="mkactdefine.msgDefName" prepend=" and ">
mad.msg_def_name=#mkactdefine.msgDefName#
</isNotEmpty>
<isNotEmpty property="mkactdefine.idList" prepend=" and ">
mad.id
<iterate property="mkactdefine.idList" close=")" open="in("
conjunction=",">
<![CDATA[
#mkactdefine.idList[]#
]]>
</iterate>
</isNotEmpty>
<isNotNull property="mkactdefine.actEndDate" prepend="and">
<![CDATA[
mad.act_end_date > date_add(CURRENT_DATE(), interval -1 day)
]]>
</isNotNull>
</dynamic>
order by mad.created_date desc
LIMIT #limitStart#,#pageSize#;
</select>
group_concat mysql
oracle wm_concat(column)函数使我们经常会使用到的,下面就教您如何使用oraclewm_concat(column)函数实现字段合并,如果您对oracle wm_concat(column)函数使用方面感兴趣的话,不妨一看。
shopping:
-----------------------------------------
u_id goods num
------------------------------------------
1 苹果 2
2 梨子 5
1 西瓜 4
3 葡萄 1
3 香蕉 1
1 橘子 3
=======================
想要的结果为:
--------------------------------
u_id goods_sum
____________________
1 苹果,西瓜,橘子
2 梨子
3 葡萄,香蕉
---------------------------------
- select u_id, wmsys.wm_concat(goods) goods_sum
- from shopping
- group by u_id
想要的结果2:
--------------------------------
u_id goods_sum
____________________
1 苹果(2斤),西瓜(4斤),橘子(3斤)
2 梨子(5斤)
3 葡萄(1斤),香蕉(1斤)
---------------------------------
使用oracle wm_concat(column)函数实现:
- select u_id, wmsys.wm_concat(goods || ‘(‘ || num || ‘斤)‘ ) goods_sum
- from shopping
- group by u_id