在旋转时连接列

时间:2016-11-16 17:51:35

标签: sql sql-server

我的代码如下

ASturct * array[]

我想在最终结果中将FTPUsername和FTPPassword连接到Deliverylocation。

以上代码无效。如果我删除+ FTPUsername + FTPPassword,那么代码可以正常工作。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

如果在子查询中进行连接,以便可以在PIVOT

中使用该列,该怎么办?
SELECT  Customerid ,
        CustomerName ,
        [ftga.ihs.com] AS ftga ,
        [Email Delivery] AS Email
FROM    ( SELECT    Customerid ,
                    CustomerName ,
                    AliasName ,
                    Deliverylocation ,
                    FTPUsername ,
                    FTPPassword ,
                    ConcatenatedValue = Deliverylocation + FTPUsername
                    + FTPPassword
          FROM      [dbo].[tblCustomerDeliveryServerMapping] t1
                    INNER JOIN tblDeliveryServerDetails t2 ON t1.Deliveryserverid = t2.id
                    INNER JOIN tblcustomerinfo t3 ON t1.customerid = t3.id
        ) AS P PIVOT 
    ( MAX(ConcatenatedValue) FOR AliasName IN ( [ftga.ihs.com],
                                                [Email Delivery] ) ) AS PVT;