2

嗨,我有两个表代理、技能和目标查询,如下所示

代理

-------------------------------------
PF       |Name       |HireDate       |
---------|-----------|---------------|
54       |Jack       |01-Jan-2012    |
55       |Aline      |01-Jan-2012    |
-------------------------------------

技能

-------------------------------------------------------------
PF       |Writing    |Swimming       |KickOff    |Shopping   |
---------|-----------|---------------|-----------------------
54       |Null       |01-Dec-2012    |Null       |Null       |
55       |01-Mar-2012|01-FeB-2012    |Null       |15-Nov-2012|
-------------------------------------------------------------

我想查询选择 PF,从 Agents 表中 Hiredate 和从 Skills 表中的可用技能, Skills 表上的日期意味着代理人在这个数据上学习了这个技能,但是如果有空值意味着代理人没有这个技能,但是我想用列名替换日期下表说明我的查询是什么

我的查询

------------------------------------------------------
PF       |HireDate       |Avalivble skills            |
---------|---------------|----------------------------|
54       |01-Jan-2012    |Swimming                    |
55       |01-Jan-2012    |Writing, Swimming, Shopping |
------------------------------------------------------
4

1 回答 1

1
select  PF
,       HireDate
,       replace(
            iif(Writing is null;'';'Writing, ') +
            iif(Swimming is null;'';'Swimming, ') +
            iif(KickOff is null;'';'KickOff, ') +
            iif(Shopping is null;'';'Shopping, ') + '$';
            ', $'; '')
from    Agents a
join    Skills s
on      s.PF = a.PF
于 2013-01-31T13:54:33.420 回答