У меня есть системная версионная таблица с именем Archiv.liste, и я хочу сравнить 12 дат с суммой прибыли.
Есть ли лучший способ сделать это, чем через UNION?
SELECT BranchCO AS Branch --> BAB01
,CAST('02.18.2019' AS DATE) AS Stichtag
,MONTH(ServiceDate) AS Leistungsmonat
,SUM(Profit) AS ProfitSum
FROM archiv.Liste FOR SYSTEM_TIME AS OF '02.18.2019' TL
GROUP BY BranchCO,MONTH(ServiceDate)
UNION
SELECT BranchCO AS Branch --> BAB02
,CAST('03.18.2019' AS DATE) AS Stichtag
,MONTH(ServiceDate) AS Leistungsmonat
,SUM(Profit) AS ProfitSum
FROM archiv.Liste FOR SYSTEM_TIME AS OF '03.18.2019' TL
GROUP BY BranchCO,MONTH(ServiceDate)
UNION
SELECT BranchCO AS Branch --> BAB03
,CAST('04.15.2019' AS DATE) AS Stichtag
,MONTH(ServiceDate) AS Leistungsmonat
,SUM(Profit) AS ProfitSum
FROM archiv.Liste FOR SYSTEM_TIME AS OF '04.15.2019' TL
GROUP BY BranchCO,MONTH(ServiceDate)
Есть ли такая команда:
SELECT * FROM archiv.Liste FOR SYSTEM_TIME AS IN ('02.18.2019','03.18.2019','04.15.2019')