标签:rownum project hiera arch left join order by from 第一条 art
SELECT * FROM(
SELECT
[SPID]
,[PH1]
,[PH1_Code]
,[ProjectName]
,ROW_NUMBER() OVER(PARTITION BY [SPID] ORDER BY [SPID]) RowNum
FROM(
SELECT
a.[SPID]
,b.[ProjectName]
,b.[PH1] AS [PH1_Code]
,e.[Description] AS [PH1]
FROM [dbo].[CAE_SPAndTask] a
LEFT JOIN [dbo].[CAE_Task] b ON b.[CAENumber]= a.[CAENumber]
LEFT JOIN [dbo].[CAE_PH1PH2] e ON e.[ProductHierarchy] = b.[PH1]
)t4
GROUP BY [SPID],[ProjectName],[PH1_Code],[PH1]
)t5
WHERE RowNum = 1
标签:rownum project hiera arch left join order by from 第一条 art
原文地址:https://www.cnblogs.com/johnblogs/p/10136791.html