如何将这三个查询合并为一个,以便可以从此查询创建单个视图?
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