码迷,mamicode.com
首页 > 数据库 > 详细

mysql 行列转换

时间:2016-07-25 18:10:57      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

CREATE OR REPLACE VIEW assign_view AS
SELECT a.event_batch_id AS event_batch_id,
(SELECT concat(u.firstname,‘ ‘,u.lastname) FROM user u WHERE u.id = a.user_id) AS user_name,
date(a.creation_date) AS creation_date,
group_concat(k.content) AS kpi,
a.created_by AS created_by,
NOW() AS update_date,
a.created_by AS updated_by,
0 as version,
true as enabled
FROM assign a, kpi k
WHERE a.enabled = 1 and k.id = a.kpi_id
GROUP BY a.event_batch_id;

mysql 行列转换

标签:

原文地址:http://www.cnblogs.com/ly-radiata/p/5704328.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!