SELECT *
FROM
(SELECT *
FROM Dim_Placement pl
OUTER JOIN
Fact_Media_KPI j1
ON pl.SK_Placement_ID = j1.FK_SK_Placement_ID
) a1
OUTER JOIN
(SELECT j1.*, pa.Package_Type, pa.Placement_Type, pa.Cost_Method, pa.Package_Name, pa.Package_Start_Date, pa.Package_End_Date,pa.Unit_Amount,pa.Unit_Rate,pa.Unit_Type
FROM Dim_Package pa
OUTER JOIN
Fact_Media_KPI j1
ON pl.SK_Package_ID = j1.FK_SK_Package_ID) a2
ON a1.SK_Fact_MEDIAKPI_ID = a2.SK_Fact_MEDIAKPI_ID ) b1
OUTER JOIN
(SELECT j1.*, b.Brand_Name, b.Op_Co, b.Category
FROM Dim_Brand b
OUTER JOIN
Fact_Media_KPI j1
ON pl.SK_Brand_ID = j1.FK_SK_Brand_ID
) a3
OUTER JOIN
(SELECT j1.*, c.Budget_Campaign_Code, c.Campaign_Start_Date, c.Campaign_End_Date, c.Campaign_Status
FROM Dim_Campaign c
OUTER JOIN
Fact_Media_KPI j1
ON pl.SK_Campaign_ID = j1.FK_SK_Campaign_ID
) a4
ON a3.SK_Fact_MEDIAKPI_ID = a4.SK_Fact_MEDIAKPI_ID) b2
ON b1.SK_Fact_MEDIAKPI_ID = b2.SK_Fact_MEDIAKPI_ID) c1
OUTER JOIN
(SELECT j1.*, s.Site_Name
FROM Dim_Site s
OUTER JOIN
Fact_Media_KPI j1
ON pl.SK_Site_ID = j1.FK_SK_Site_ID
) a5
OUTER JOIN
(SELECT j1.*,c.Creative_Adname, c.Creative_Filename, c.Click_Through_URL, c.Creative_ID, c.Creative_Size c.Creative_Type, c.Video_Length
FROM Dim_Creative c
OUTER JOIN
Fact_Media_KPI j1
ON pl.SK_Site_ID = j1.FK_SK_Site_ID
) a6
ON a5.SK_Fact_MEDIAKPI_ID = a6.SK_Fact_MEDIAKPI_ID) b3
OUTER JOIN
(SELECT j1.*, d.Date
FROM Dim_Site s
OUTER JOIN
Fact_Media_KPI j1
ON pl.SK_Date_ID = j1.FK_SK_Date_ID
) a7
ON b3.SK_Fact_MEDIAKPI_ID = a7.SK_Fact_MEDIAKPI_ID) c2
ON c1.SK_Fact_MEDIAKPI_ID = c2.SK_Fact_MEDIAKPI_ID
WHERE d.Date >= '2015-01-01';
间距也变得太可怕了。出了什么问题 - 有了这么多联接,这个错误大多没有意义。
我收到一个错误,称为156错误 - JOIN附近的语法错误
一个问题 - 哪个加入?
据我所知,嵌套的从属子查询是合法的。想法?
(另外,这个尺寸,让我很难发布。为什么要堆叠为什么?)
答案 0 :(得分:2)
您只是为im
说OUTER JOIN
,但您需要指定哪种类型。它们可以是JOIN
,RIGHT OUTER JOIN
或LEFT OUTER JOIN
。
有关不同FULL OUTER JOIN
类型的更多信息,请参阅此帖子:What is the difference between "INNER JOIN" and "OUTER JOIN"?