SQL merge fields

Source: Internet
Author: User
Tags cdata pears

<!--merge queries on the Send method--
<!--Find all eligible marketing activities--
<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-sent_way_value = ' SMS ' Then ' text message ' when sent_way_value = ' Mail ' Then ' mail ' 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

The Oracle Wm_concat (column) function allows us to use it frequently, and below teaches you how to use the Oraclewm_concat (column) function to implement a field merge if you have an Oracle Wm_concat (column) If you are interested in the use of functions, you may wish to take a look.

Shopping:

-----------------------------------------

U_ID Goods num

------------------------------------------

1 Apples 2

2 Pear 5

1 Watermelon 4

3 Grapes 1

3 Banana 1

1 Oranges 3

=======================

The desired result is:

--------------------------------

u_id Goods_sum

____________________

1 apples, watermelon, oranges

2 Pears

3 Grapes, Banana

---------------------------------

    1. Select u_id, Wmsys.wm_concat (goods) goods_sum
    2. From shopping
    3. GROUP BY u_id

Desired result 2:

--------------------------------

u_id Goods_sum

____________________

1 apples (2 kg), watermelon (4 kg), Orange (3 kg)

2 pears (5 kg)

3 grapes (1 kg), banana (1 kg)

---------------------------------

Using the Oracle Wm_concat (column) function:

    1. Select u_id, wmsys.wm_concat (Goods | | ' (' | | | num | | ' kg ') goods_sum
    2. From shopping
    3. GROUP BY u_id

SQL merge fields

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.