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 句の使用を認識していません。
ありがとう