Joining Two Subqueries That Contain A Subquery
Joining Two Subqueries That Contain A Subquery Still new to SQL. I have looked around for an answer on this, and the examples that I have found, I have mirrored my query to look like the examples, and this query still isn't working. All Im trying to do is join two subqueries, but both of these subqueries contain a subquery inside. I'm receiving the following error: Msg 156, Level 15, State 1, Line 26 Incorrect syntax near the keyword 'On'. This is the query, please assist, thank you. Select * From ( Select * From( Select x.ID, x.Date, x.USOHist, x.OVXHist, Abs(Cast((((x.USOHist / NullIf((y.USOHist),0))-1)*100) as Decimal(10,2))) AS '%USOH', Abs(Cast((((x.OVXHist / NullIf((y.OVXHist),0))-1)*100) as Decimal(10,2))) AS '%OVXH' From (Select a.Date as aDate, Max(b.Date) As aPrevDate From USO_OVX_Hist a Inner Join USO_OVX_Hist b on a.Date > b.Date Group By a.Date) Sub1 Inner Join USO_OVX_Hist x on Sub1.aDate = x.Date Inner Join USO_OVX_Hist...
