Sql 为什么我有重复的月号
我不明白,为什么这个查询的结果显示重复的月份和不同的sumbmission计数:Sql 为什么我有重复的月号,sql,tsql,reporting-services,count,Sql,Tsql,Reporting Services,Count,我不明白,为什么这个查询的结果显示重复的月份和不同的sumbmission计数: [![SELECT CAST(B.YearNum as varchar(10))+ ' Submitted' as Type, 1 as OrderNum, COUNT( ControlNo) Count, b.YearNum, b.MonthNum FROM tblCalendar
[![SELECT CAST(B.YearNum as varchar(10))+ ' Submitted' as Type,
1 as OrderNum,
COUNT( ControlNo) Count,
b.YearNum, b.MonthNum
FROM tblCalendar b
LEFT JOIN ClearanceReportMetrics a ON b.MonthNum = MONTH(a.EffectiveDate) AND b.YearNum=YEAR(a.EffectiveDate)
AND CompanyLine = 'Plaza Insurance Company' AND Underwriter <> 'Batcheller, Jerry'
WHERE YEAR(EffectiveDate) IN (2016, 2015,2014)
GROUP BY b.YearNum, b.MonthNum, Type
order by b.YearNum, b.MonthNum][1]][1]
[![SELECT CAST(B.dearneum作为varchar(10))+“Submitted”作为类型,
1作为OrderNum,
计数(控制否)计数,
b、 b.蒙特纳姆
来自tblCalendar b
左连接ClearanceReportMetrics a在b.MonthNum=月(a.EffectiveDate)和b.eargnum=年(a.EffectiveDate)上
和CompanyLine=‘Plaza保险公司’和保险商‘Batcheller,Jerry’
其中年份(生效日期)在(2016、20152014)
按b.Dearneum、b.MonthNum、类型分组
b.Dearneum、b.MonthNum的订单][1][1]
最有可能的源表中有一个具有
类型
列
select year + 1 as type, count(*)
from (
values
(1, 2014, 1)
, (2, 2014, 2)
) t (id,year, type)
group by year, type
最有可能的是,其中一个源表具有
type
列
select year + 1 as type, count(*)
from (
values
(1, 2014, 1)
, (2, 2014, 2)
) t (id,year, type)
group by year, type
天啊!!!你说得太对了!!!我怎么没注意到!塞格,非常感谢!!!!天啊!!!你说得太对了!!!我怎么没注意到!塞格,非常感谢!!!!