group_concat 的使用 [英] Use of group_concat

查看:66
本文介绍了group_concat 的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 LOPList 的表:

I have following a table called LOPList:

我希望结果是:

LOPID | EMP ID | TIME START (LOPStatus = 'Y') | TIME END (LOPStatus = 'N')

2     | 6      | 2016-03-24T20:05:27+00:00    | 2016-03-24T20:14:41+00:00

5     | 6      | 2016-03-24T20:07:59+00:00    | 2016-03-24T20:13:11+00:00

推荐答案

尝试:

select LOPID,EmpId,
max(case when LOPStatus='Y' then TimeUpdated end) as time_start,
max(case when LOPStatus='N' then TimeUpdated end) as time_end  
from LOPList where JobID= 22 group by LOPID;

这篇关于group_concat 的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆