美文网首页
mysql 多行数据合并一行 GROUP_CONCAT

mysql 多行数据合并一行 GROUP_CONCAT

作者: 爱吃苹果的西瓜 | 来源:发表于2020-01-02 10:00 被阅读0次

    group_concat

    SELECT 
      t.application_id,
      t.submit_by,
      t.dept_code,
      t.create_time,
      t.complete_time,
      t.`process_id`,
      t_hi_new.assignee
    FROM
      t_application_info t 
      LEFT JOIN 
        (SELECT 
          t_hi.`PROC_INST_ID_` AS process_id,
          GROUP_CONCAT(CONCAT(t_hi.`ASSIGNEE_`)) AS assignee 
        FROM
          act_hi_taskinst t_hi 
        GROUP BY PROC_INST_ID_) t_hi_new 
        ON t.`process_id` = t_hi_new.process_id 
    WHERE t.`application_type` IN ('50603') 
      AND UNIX_TIMESTAMP(t.create_time) > UNIX_TIMESTAMP('2019-01-01 00:00:00') 
      AND UNIX_TIMESTAMP(t.complete_time) < UNIX_TIMESTAMP('2019-12-31 23:59:59') ;
    

    相关文章

      网友评论

          本文标题:mysql 多行数据合并一行 GROUP_CONCAT

          本文链接:https://www.haomeiwen.com/subject/khpnoctx.html