2016-11-16 109 views

回答

0

爲此,您可以使用左連接和ROW_NUMBER窗函數。 請在運行此查詢之前檢查列的正確性。

SELECT T2.[Operation cancelled within 28 days] 
     ,T2.[Number of new patients seen] 
     ,T2.[Number of follow up patients seen] 
     ,T2.[Readmission Rate] 
     ,T2.[2 Week Target] 
     ,T1.[Procedure Split] 
FROM 
    (SELECT DISTINCT [Operation cancelled within 28 days] 
        ,[Procedure Split] 
        ,ROW_NUMBER() OVER(ORDER BY NUM) AS RN FROM Your_table) T1 

LEFT JOIN 

    (SELECT * FROM (SELECT DISTINCT [Operation cancelled within 28 days] 
            ,[Number of new patients seen] 
            ,[Number of follow up patients seen] 
            ,[Readmission Rate] 
            ,[2 Week Target] 
            ,ROW_NUMBER() OVER(ORDER BY A) AS RN FROM Your_table) X 
    WHERE RN=1) T2 
ON T1.RN = T2.RN 
相關問題