Multi select в SQL server
дорогие все,
у меня есть 3 SQL оператора я хочу объединить их в один но каждый из них имеет свое собственное условие where как я могу их объединить
1-й:
SELECT ProjectCode, SUM (- 1 *(CreditAm) +(DebitAm)) AS Balance FROM [dbo].[AcDetail] WHERE AcCode IN ( 401000, 402000, 403000, 404000, 405000, 406000, 407000, 499999 ) AND BranchCode = 'WP' AND TDate >= '2016-01-01' AND TDate <= '2016-12-31' GROUP BY ProjectCode
2-й
SELECT ProjectCode, SUM (- 1 *(CreditAm) +(DebitAm)) AS Materials FROM [dbo].[AcDetail] WHERE AcCode IN (600001, 600002, 600151) AND BranchCode = 'WP' AND TDate >= '2016-01-01' AND TDate <= '2016-12-31' GROUP BY ProjectCode
3-й:
SELECT ProjectCode, SUM (- 1 *(CreditAm) +(DebitAm)) AS Salaries FROM [dbo].[AcDetail] WHERE AcCode IN ( 650001, 650005, 650006, 650007, 650008, 650009, 650010, 650020, 650021, 650022, 650023, 650024, 650025, 650026, 650027 ) AND BranchCode = 'WP' AND TDate >= '2016-01-01' AND TDate <= '2016-12-31' GROUP BY ProjectCode ORDER BY ProjectCode
Что я уже пробовал:
SELECT ProjectCode, SUM (- 1 *(CreditAm) +(DebitAm)) AS Balance FROM [dbo].[AcDetail] WHERE AcCode IN ( 401000, 402000, 403000, 404000, 405000, 406000, 407000, 499999 ) AND BranchCode = 'WP' AND TDate >= '2016-01-01' AND TDate <= '2016-12-31' GROUP BY ProjectCode