0

このクエリから単一のビューを作成できるように、これら 3 つのクエリを単一のクエリにするにはどうすればよいですか?

CREATE VIEW v1 AS
SELECT rp.ProjectName, rp.TaxRegime, rp.CashflowReportProfilePrimaryKey_ReportPrimaryKey FROM ReportProfiles rp
WHERE rp.CashflowReportProfilePrimaryKey_ReportPrimaryKey IS NOT NULL
GROUP BY rp.ProjectName, rp.TaxRegime, rp.CashflowReportProfilePrimaryKey_ReportPrimaryKey

CREATE VIEW v2 AS
SELECT vd.Year, vd.Data, r.ReportPrimaryKey FROM VectorData vd, Reports r
WHERE vd.FK_Vector = r.Pretax_VectorID AND vd.Data != 0 AND LEN(r.Name) < 1

SELECT v1.ProjectName, v1.TaxRegime, v2.Year, FORMAT(v2.Data, 'N', 'nb-NO') FROM v1, v2
WHERE v1.CashflowReportProfilePrimaryKey_ReportPrimaryKey = v2.ReportPrimaryKey
ORDER BY v1.ProjectName, v2.Year
4

1 に答える 1