Queries: FROM, joins, APPLY, PIVOT, temporal, graph
26 reference entries
- CROSS APPLY / OUTER APPLY
CROSS APPLY keeps left rows with at least one right row; OUTER APPLY keeps all left rows with NULLs
- CROSS JOIN
every left row paired with every right row
- FOR SYSTEM_TIME ALL
FOR SYSTEM_TIME ALL: every current and historical row
- FOR SYSTEM_TIME AS OF
FOR SYSTEM_TIME AS OF: rows valid at one point in time
- FOR SYSTEM_TIME BETWEEN ... AND
FOR SYSTEM_TIME BETWEEN..AND: like FROM..TO but includes rows starting at the upper bound
- FOR SYSTEM_TIME CONTAINED IN
FOR SYSTEM_TIME CONTAINED IN: rows opened and closed inside the period
- FOR SYSTEM_TIME FROM ... TO
FOR SYSTEM_TIME FROM..TO: rows active in the half-open period
- FROM - Using PIVOT & UNPIVOT
implicit GROUP BY on remaining columns, aggregate of value_column, spread by pivot_column
- FROM ... WITH ( table_hint )
constrains access method or locking for one table reference
- FROM derived table
nested query used as a table
- FROM OPENXML
shreds XML into rows
- FROM plus JOIN, APPLY, PIVOT
binds sources and composes them with joins, APPLY, PIVOT, UNPIVOT
- FROM rowset_function
row source produced by a rowset function
- FROM table_or_view_name
row source
- FROM table-valued function
inline TVF expands like a parameterized view; multi-statement TVF is a module filling a return table
- FULL OUTER JOIN
FULL OUTER JOIN: all rows from both sides; unmatched sides padded with NULL
- INNER JOIN
INNER JOIN: only matching pairs
- Join hint in FROM
forces the physical join algorithm for one join
- LEFT OUTER JOIN
LEFT OUTER JOIN: all left rows; unmatched right columns become NULL
- MATCH
graph pattern match: node-(edge)->node chains act as joins on $from_id/$to_id
- PIVOT
implicit GROUP BY on remaining columns, aggregate of value_column, spread by pivot_column
- RIGHT OUTER JOIN
RIGHT OUTER JOIN: all right rows; unmatched left columns become NULL
- SHORTEST_PATH
arbitrary-length shortest path search
- Table value constructor
builds rows inline (VALUES)
- TABLESAMPLE
page-level random sample (SYSTEM), REPEATABLE seed optional
- UNPIVOT
turns listed columns into rows (NULL values are dropped)