MySQL實現把兩行兩列資料合併為一行一列

2021-08-15 02:12:32 字數 1272 閱讀 4091

最近在oa專案中使用acitiviti中,遇到乙個排他閘道器有多個判斷條件(),並且可以多次執行,在顯示已辦任務的時候要歸屬為一條資料,利用group_concat和concat加上group by 解決。

詳細sql如下:

select

aht.id_ as id,

ard.name_ as processname,

aht.name_ as name ,

art.name_ as currentname,

csp.post_name as postname,

group_concat(concat(ahd.name_,':',ahd.text_)) as message,

ahp.end_time_ as endtime

from

act_hi_taskinst aht left join act_re_procdef arp on aht.proc_def_id_ = arp.id_

inner join act_re_procdef_ext arpe on arp.id_ = arpe.act_re_procdef_id

left join act_re_deployment ard on arp.deployment_id_ = ard.id_

left join act_ru_task art on aht.execution_id_ = art.execution_id_

left join cf_sys_post csp on art.assignee_ = csp.id

left join act_hi_actinst aha on aha.task_id_ = aht.id_

left join act_hi_detail ahd on aha.id_ = ahd.act_inst_id_

left join act_hi_procinst ahp on aht.proc_inst_id_ = ahp.proc_inst_id_

where

aht.id_ in (

select

ahte.act_hi_taskinst_id

from

act_hi_taskinst_ext ahte

where

ahte.complete_status = '1'

and ahte.proxy_id = #

or ahte.handle_id = #

)group by aht.id_

order by aht.start_time_ desc

mysql交換兩行或兩列的值

參考 mysql left join中where和on條件的區別 新建資料庫和表,並插入資料 create database test use test create table product id int 10 unsigned not null auto increment comment 產...

awk輸出相同列的前兩行和後兩行

要求列印,第一列相同的頭兩行和後兩行 file ax bx 1 ax bx 2 ax bx 1 ax bx 8 ax bx 1 ax bx 3 ax bx 5 cx bx 1 cx bx 0 cx bx 1 cx bx 6 cx bx 9 ex bx 1 ex bx a ex bx 1 ex bx ...

用sql實現兩行記錄合併為一行記錄

偶然遇到同學問了個sql的問題,閒著沒事搗鼓了一下。他的問題是 如何把下面這樣的資料,每兩行資料按照第乙個字段合併為一行。create table tp user user no varchar2 2char user name varchar2 10 char user no user name ...