老问题解决有难度需帮助
declare @BeginDate datetime
declare @EndDate datetime
declare @Staion nvarchar(50)
set @BeginDate ='2013-01-01'
set @EndDate ='2015-01-01'
set @Staion ='1301'
select A.[RDDate], A.[RDYBName],
case when A.RdBanci ='1' then '早班' else '夜班' end as 班次,
sum(case when A.RDMemos ='高流量' then A.RDLong else 0 end) as 高流量,
sum(case when A.RDMemos='低流量' then A.RDLong else 0 end) as 低流量,
sum(case when A.RDMemos='空流量' then A.RDLong else 0 end) as 空流量,
count(case when A.RDMemos ='高流量' and A.RDLong >15 then 0 else 0 end) as 高流量次数,
count(case when A.RDMemos='低流量' and A.RDLong >15 then 0 else 0 end) as 低流量次数,
count(case when A.RDMemos='空流量' and A.RDLong >15 then 0 else 0 end) as 空流量次数,
sum(B.[作业吨位]) as 累计量
FROM [OneWeight].[dbo].[tbRunAlarm] A
Left outer join [OneWeight].[dbo].[gs_zyjl] B on A.RDDate =B.操作日期
where left(A.RDDate,10) between @BeginDate and @EndDate and A.RDYBName like '%'+@Staion +'%'
group by A.[RDDate],A.[RDYBName],A.RdBanci
order by A.[RDDate],A.[RDYBName],A.RdBanci
其他都正确,就是三个统计次数不正确,求解
------解决方案--------------------gxgxgx
------解决方案--------------------留个脚印,以后参考用
------解决方案--------------------楼主厉害,自己搞定了