Was looking at the railroad-diagrams (very cool!) and was curious why the table-alias was not right after the table: from users for valid_time as of TIMESTAMP ? u1 instead of from users u1 for valid_time as of TIMESTAMP ? 🤔
Seems to match SQL Server: https://learn.microsoft.com/en-us/sql/relational-databases/tables/querying-data-in-a-system-versioned-temporal-table?view=sql-server-ver16
DECLARE @ADayAgo DATETIME2;
SET @ADayAgo = DATEADD(DAY, -1, SYSUTCDATETIME());
-- Comparison between two points in time for subset of rows
SELECT D_1_Ago.[DeptID],
D.[DeptID],
D_1_Ago.[DeptName],
D.[DeptName],
D_1_Ago.[ValidFrom],
D.[ValidFrom],
D_1_Ago.[ValidTo],
D.[ValidTo]
FROM [dbo].[Department]
FOR SYSTEM_TIME AS OF @ADayAgo AS D_1_Ago
INNER JOIN [Department] AS D
ON D_1_Ago.[DeptID] = [D].[DeptID]
AND D_1_Ago.[DeptID] BETWEEN 1 AND 5;yeah, this is one from the SQL spec I'm afraid, it's caught me out a good few times too 😅
my guess at the intuition is that it's naming the filtered relation rather than the base table, i.e. "(table for valid time ...) as foo"
legacy 🙂