如何将三列中的数据检索到新表SQL中的一列中

时间:2018-06-08 03:19:19

标签: sql sql-server-2014

SELECT  Dc.Name AS Market   
        ,R.Name AS Route    
        ,C.Id   
        ,C.ERPCusCode   
        ,C.Name 
        ,C.Address1 AS Address  
        ,C.CustomerGradeId AS volumeClass   
        ,I.ERPItemCode  
        ,H.InvoiceDate  
        ,D.Qty 
FROM InvoiceHeader H
INNER JOIN InvoiceDetail D ON H.InvoiceNo=D.InvoiceNo
INNER JOIN ItemMaster I ON I.Id=D.ItemMasterId
INNER JOIN Customer C ON C.Id=H.CustomerId
INNER JOIN DistributionCenter Dc ON Dc.Id=H.DistributionCenterId
INNER JOIN Route R ON R.Id=H.RouteId
WHERE H.Deleted=0 AND H.InvoiceDate BETWEEN '2018/01/01' AND '2018/06/06'
AND C.Active=1

这是我的SQL代码,客户表中有地址1,地址2,地址3,地址4,我希望将所有字段数据作为地址输入到上面的代码输出表中的一列。我该怎么办?它?

1 个答案:

答案 0 :(得分:0)

你能把它们连在一起吗?

(address1 + ' ' + address 2 + ' ' + address 3 + ' ' + address 4) as address