因此,在我的查询中,我需要重组一些数据。
为此,我创建了select语句,这些语句将某些集合选择到表中,然后事先检查它是否存在,然后删除该表是否存在。 每当我必须运行SSIS程序包时,这些表都会重新填充,并且我觉得如果我继续走这条路的话,事情将会变得混乱。
在select语句中间是否可以从select语句中进行选择?
Select Field1
,Field2
,Field3
,SELECT DISTINCT R.Field4
FROM
(
SELECT DISTINCT
L.Open_DT
,L.Group_NPI
, bil.*
,Row_Number() over (partition by group_npi order by L.open_dt) AS RNK
FROM tbl_Location L
LEFT OUTER JOIN [MOAD].[dbo].[qry_Location_Address_Billing] bil
ON L.Location_ID = bil.Location_ID
) AS R
WHERE Rnk = 1 AND Location_ID IS NOT NULL AS Field4,
,Field5
,Field6
From Tables
我已尝试澄清此问题。
我希望它像这样出来:
Field1, Field2, Field3, Field4 (from that nested query), Field5, Field6