请任何人都可以帮助我理解 WITH 子句的使用
WITH T(Id) AS
(SELECT DISTINCT
[IO].[IncidentQuestionId]
FROM
[dbo].[IncidentValue] AS IV
INNER JOIN
[dbo].[IncidentOption] AS [IO] ON [IV].[IncidentOptionId] = [IO].[Id]
WHERE
[IV].[IncidentId] = 45
)
SELECT
IQ.*, IC.[Name] AS [IncidentCategory]
FROM
IncidentQuestion] AS IQ
INNER JOIN
T ON [T].[Id] = IQ.[Id]
INNER JOIN
[dbo].[IncidentCategory] AS IC ON IQ.[IncidentCategoryId] = IC.[Id]
WHERE
IQ. [IsOption] = 0
ORDER BY
IC.[OrderId] ASC, IQ.[OrderId] ASC
我有上面使用 with 子句的查询,但我不知道使用 with 子句。
谢谢