Sql (T1.[服务]“空中救护”)和(T1.服务=收入_Tracker_new$.Service)),

Sql (T1.[服务]“空中救护”)和(T1.服务=收入_Tracker_new$.Service)),,sql,sql-server,tsql,Sql,Sql Server,Tsql,尝试将这两个查询组合为两个查询。请帮忙 Select count(distinct([Lead Number])) 'Total service given for the day - ', sum(Amount) 'Revenue for the Day - ', sum([MUrgency Fee]) 'MUshare for the Day - ' from Revenue_Tracker_new$ where Revenue_Tracker_new$.[From Date (If

尝试将这两个查询组合为两个查询。请帮忙

Select
count(distinct([Lead Number])) 'Total service given for the day  - ',
sum(Amount) 'Revenue for the Day  - ',
sum([MUrgency Fee]) 'MUshare for the Day  - '
from Revenue_Tracker_new$
where Revenue_Tracker_new$.[From Date (If Long Term)]='2017-10-17'and
Revenue_Tracker_new$.[Service]<>'Air Ambulance'


Select
count(distinct([Lead Number])) 'Total service given for the day  - ',
sum(Amount) 'Revenue for the Day  - ',
sum([MUrgency Fee]) 'MUshare for the Day  - '
from Revenue_Tracker_new$
where Revenue_Tracker_new$.[From Date (If Long Term)]='2017-10-17'and
Revenue_Tracker_new$.[Service]='Air Ambulance'
从where子句中删除服务条件


SQL server 2017将文本UNION ALL放在两个查询之间。您的问题没有包含足够的详细信息。您想如何组合它们?水平的?如果是,您是想要所有结果,还是要删除重复的结果?或者,您可能只希望在两个结果库中都显示结果?或者你只想要一个结果集中的结果,而不是另一个?事实上……我认为查询之间的唯一区别是“空中救护”或=“空中救护”。这意味着您可以从第一个查询中删除WHERE子句,并进行单个查询!假设您正在寻找一个水平连接,我需要在一行中显示两个查询结果,这些是具有两个不同条件的结果,我需要在一行中显示这些结果
Select
count(distinct([Lead Number])) 'Total service given for the day  - ',
sum(Amount) 'Revenue for the Day  - ',
sum([MUrgency Fee]) 'MUshare for the Day  - '
from Revenue_Tracker_new$
where Revenue_Tracker_new$.[From Date (If Long Term)]='2017-10-17'