You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WITH [CTE1] AS (
SELECT
[Col1],
MAX([Col2]) AS [MaxCol2]
FROM
[Table1]
GROUP BY
[Col1]
)
SELECT
t1.[ColA] AS [PortfolioCode], -- Portfolio unique identifier
t2.[ColB] AS [InstrumentCode], -- Instrument unique identifierSUM(t3.[Qty1]) AS [OutstandingQuantity],
SUM(t3.[Qty2]) AS [InstrumentValuation],
t4.[Code] AS [ValuationCurrency],
t3.[DateCol] AS [RefDate]
FROM
[Table1] t3
JOIN [CTE1] t1 ON t3.[Col1] = t1.[Col1] AND t3.[DateCol] = t1.[MaxCol2]
JOIN [Table2] t4 ON t4.[ID] = t3.[Col2]
JOIN [Table3] t1 ON t1.[ID] = t3.[Col3]
JOIN [Table4] t2 ON t2.[ID] = t3.[Col4] AND (t2.[Code] LIKE @Param1)
WHERE
t3.[Qty1] <>0GROUP BY
t1.[ColA],
t2.[ColB],
t4.[Code],
t3.[DateCol];
Version: sql_metadata==2.13.0
The text was updated successfully, but these errors were encountered:
Using the method
parser.tables_aliases
it brings backGROUP BY
as a table alias in MSSQL.Executed sql query:
Version:
sql_metadata==2.13.0
The text was updated successfully, but these errors were encountered: