派生テーブルを使用した次の SQL クエリがあり、そのため、インデックス付きビューの CLUSTERED INDEX を作成できません。したがって、派生テーブルを通常の結合に変換する必要があります。
SELECT
......
FROM
dbo.invoice i
LEFT JOIN
(
SELECT SUM(amount) as servicesamount
,ise.invoiceuid
,ise.episodeuid
,ise.memberuid
,ev.caseuid
FROM dbo.invoice_services ise
JOIN dbo.invoice inv on inv.invoiceuid = ise.invoiceuid
JOIN dbo.event ev ON ev.eventuid = ise.episodeuid -- JOIN IN ORDER TO BRING EVENT INVOCIES ONLY (DENTAL INVOICES COULD EXIST)
GROUP BY ise.invoiceuid,ise.episodeuid,ise.memberuid,ev.caseuid
) ise ON ise.invoiceuid = i.invoiceuid
変換方法の手がかり
LEFT JOIN
(
SELECT SUM(amount) as servicesamount
,ise.invoiceuid
,ise.episodeuid
,ise.memberuid
,ev.caseuid
FROM dbo.invoice_services ise
JOIN dbo.invoice inv on inv.invoiceuid = ise.invoiceuid
JOIN dbo.event ev ON ev.eventuid = ise.episodeuid -- JOIN IN ORDER TO BRING EVENT INVOCIES ONLY (DENTAL INVOICES COULD EXIST)
GROUP BY ise.invoiceuid,ise.episodeuid,ise.memberuid,ev.caseuid
) ise
通常加入するには?
感謝します!!