我有以下带有派生表的 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
能正常加入吗?
欣赏它!