我在这里发帖的第一个问题请原谅我犯的错误:p
我正在使用2011年的水晶报告。 我正在尝试使用2个“不同”命令进行报告,第一个应该显示所有呼叫(注意:cdr.aantal列)第二个命令应该只显示振铃时间为20或更少的那些。我只使用最后一个命令的cdr.aantal colmn并将其作为我报告的最后一列。但由于某种原因,它只是再次显示呼叫总数(不是20或更少)。 我也尝试制作1个更大的sql查询(命令),但这也没有用。
第一个命令
DECLARE @FromDate Date
DECLARE @ToDate Date
set @FromDate = ('01-07-2015')
set @ToDate = ('01-08-2015')
select [CDR].[Account], [CDR].[DnNo], COUNT ([CDR].[ID])[aantal], SUM([CDR].[Duration] [Duration], [CDR].[CdrDate], [Departments].[Description]
from [PhonEXONE].[MIND].[CDR]
Inner join [PhonEXONE].[MIND].[AllAssignmentsView]
on [CDR].[DeviceID] = [AllAssignmentsView].[DeviceID]
inner join [PhonEXONE].[MIND].[Departments]
on [AllAssignmentsView].[DepartmentID] = [Departments].[ID]
WHERE [CDR].[CdrDate] >= @FromDate AND [CDR].[CdrDate] <= @ToDate
group by [CDR].[DnNo] ,[CDR].[Account], [CDR].[CdrDate], [Departments].[Description]
order by [CDR].[DnNo]
第二个命令
DECLARE @FromDate Date
DECLARE @ToDate Date
set @FromDate = ('01-07-2015')
set @ToDate = ('01-08-2015')
select [CDR].[Account], [CDR].[DnNo], COUNT ([CDR].[ID])[aantal], SUM([CDR].[Duration] [Duration], [CDR].[CdrDate], [Departments].[Description]
from [PhonEXONE].[MIND].[CDR]
Inner join [PhonEXONE].[MIND].[AllAssignmentsView]
on [CDR].[DeviceID] = [AllAssignmentsView].[DeviceID]
inner join [PhonEXONE].[MIND].[Departments]
on [AllAssignmentsView].[DepartmentID] = [Departments].[ID]
WHERE [CDR].[CdrDate] >= @FromDate AND [CDR].[CdrDate] <= @ToDate
AND [CDR].[RingTime] >= '20'
group by [CDR].[DnNo] ,[CDR].[Account], [CDR].[CdrDate], [Departments].[Description]
order by [CDR].[DnNo]
这是我的1个更大的sql
DECLARE @FromDate Date
DECLARE @ToDate Date
set @FromDate = ('01-07-2015')
set @ToDate = ('01-08-2015')
select A.[Account], A.[DnNo], A.[aantal], A.[TDuration], A.[CdrDate], A.[Description],B.[aantal20]
from (
select [CDR].[Account], [CDR].[DnNo], COUNT([CDR].[ID])[aantal], SUM([CDR].[Duration]) [TDuration], [CDR].[CdrDate], [Departments].[Description]
From [PhonEXONE].[MIND].[CDR]
Inner join [PhonEXONE].[MIND].[AllAssignmentsView]
on [CDR].[DeviceID] = [AllAssignmentsView].[DeviceID]
inner join [PhonEXONE].[MIND].[Departments]
on [AllAssignmentsView].[DepartmentID] = [Departments].[ID]
WHERE [CDR].[CdrDate] >= @FromDate AND [CDR].[CdrDate] <= @ToDate
group by [CDR].[DnNo] ,[CDR].[Account], [CDR].[CdrDate], [Departments].[Description]
) A left join
(select [CDR].[Account], COUNT ([CDR].[ID])[aantal20]
from [PhonEXONE].[MIND].[CDR]
WHERE [CDR].[RingTime] <= '20'
group by [CDR].[DnNo] ,[CDR].[Account], [CDR].[CdrDate]
)B
on A.Account = B.Account
order by A.DnNo
再次为我的英语道歉,如果我做错了什么
ps:我不能张贴图片:(
答案 0 :(得分:1)
我找到了答案,我的第二个命令与我的第一个命令相关联,并且不应该是这样,我删除了链接并且它有效