AnnetteB1305
Technical User
Hello,
I have a report which I've posted about before it is a subreport within another report. It shows the calls that were still open at the end of each day for a period of the last 8 days. It shows these by priority. i.e. High, Med, Low and calls that are on hold.
The report is selected from a command. The command is as follows:-
SELECT `opencall1`.`priority`,`opencall1`.`callref`, `opencall1`.`priority`, `opencall1`.`logdate`, `opencall1`.`closedate`, `mdis_status1`.`status_description`, `opencall1`.`cust_id`, `opencall1`.`suppgroup`, `updatedb1`.`updatetxt`,`company1`.`custom_f`,`company1`.`companyname`
FROM (`swdata`.`opencall` `opencall1` INNER JOIN `swdata`.`updatedb` `updatedb1` ON `opencall1`.`callref`=`updatedb1`.`callref`) INNER JOIN `swdata`.`mdis_status` `mdis_status1` ON `opencall1`.`status`=`mdis_status1`.`status_code` INNER JOIN `swdata`.`company` `company1` ON `opencall1`.`companyname`=`company1`.`companyname`
WHERE `opencall1`.`priority`<>'NL-MDIS SALES OFF SEND'
and (`opencall1`.`closedate`='' or
(concat(substring(`opencall1`.`closedate`,7,4),'-',substring(`opencall1`.`closedate`,4,2),'-',substring(`opencall1`.`closedate`,1,2),' ',
substring(`opencall1`.`closedate`,12,2),':',substring(`opencall1`.`closedate`,15,2),':',substring(`opencall1`.`closedate`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
) =1)
union all
SELECT 'All',`opencall1`.`callref`, `opencall1`.`priority`, `opencall1`.`logdate`, `opencall1`.`closedate`, `mdis_status1`.`status_description`, `opencall1`.`cust_id`, `opencall1`.`suppgroup`, `updatedb1`.`updatetxt`,`company1`.`custom_f`,`company1`.`companyname`
FROM (`swdata`.`opencall` `opencall1` INNER JOIN `swdata`.`updatedb` `updatedb1` ON `opencall1`.`callref`=`updatedb1`.`callref`) INNER JOIN `swdata`.`mdis_status` `mdis_status1` ON `opencall1`.`status`=`mdis_status1`.`status_code` INNER JOIN `swdata`.`company` `company1` ON `opencall1`.`companyname`=`company1`.`companyname`
WHERE `opencall1`.`priority`<>'NL-MDIS SALES OFF SEND'
and (`opencall1`.`closedate`='' or
(concat(substring(`opencall1`.`closedate`,7,4),'-',substring(`opencall1`.`closedate`,4,2),'-',substring(`opencall1`.`closedate`,1,2),' ',
substring(`opencall1`.`closedate`,12,2),':',substring(`opencall1`.`closedate`,15,2),':',substring(`opencall1`.`closedate`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
) =1)
union all
Select 'Hold',`opencall1`.`callref`, `opencall1`.`priority`, `opencall1`.`logdate`, `opencall1`.`closedate`, `mdis_status1`.`status_description`, `opencall1`.`cust_id`, `opencall1`.`suppgroup`, `updatedb1`.`updatetxt`,`company1`.`custom_f`,`company1`.`companyname`
FROM (`swdata`.`opencall` `opencall1` INNER JOIN `swdata`.`updatedb` `updatedb1` ON `opencall1`.`callref`=`updatedb1`.`callref`) INNER JOIN `swdata`.`mdis_status` `mdis_status1` ON `opencall1`.`status`=`mdis_status1`.`status_code` INNER JOIN `swdata`.`company` `company1` ON `opencall1`.`companyname`=`company1`.`companyname`
WHERE `opencall1`.`priority`<>'NL-MDIS SALES OFF SEND' and `updatedb1`.`updatetxt` like "%placed on hold%"
and (`opencall1`.`closedate`='' or
(concat(substring(`opencall1`.`closedate`,7,4),'-',substring(`opencall1`.`closedate`,4,2),'-',substring(`opencall1`.`closedate`,1,2),' ',
substring(`opencall1`.`closedate`,12,2),':',substring(`opencall1`.`closedate`,15,2),':',substring(`opencall1`.`closedate`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
) =1)
and
(concat(substring(`updatedb1`.`updatetime`,7,4),'-',substring(`updatedb1`.`updatetime`,4,2),'-',substring(`updatedb1`.`updatetime`,1,2),' ',
substring(`updatedb1`.`updatetime`,12,2),':',substring(`updatedb1`.`updatetime`,15,2),':',substring(`updatedb1`.`updatetime`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
=1)
ORDER BY 1
The report is then a graph and a manual crosstab. The graph is on change of command.priority and then summarising Distinct count of @count1, @count2,@count3,@count4,@count5,@count6,@count7,@count8
The @count1-@count8 formulas are:-
//@count1
If {@logdate}<=dateadd("d",-8,CurrentDate)and ({Command.closedate}='' or {@Closedate}>dateadd("d",-8,CurrentDate))
then {Command.callref} else tonumber ({@@null})
up to
//@count8
If {@logdate}<=(DateAdd("d",-1,CurrentDate))and ({Command.closedate}='' or
{@Closedate}>(DateAdd("d",-1,CurrentDate)))then {Command.callref}else tonumber ({@@null})
The @logdate formula is
date({Command.logdate})
The @closedate formula is
If {Command.closedate}<>'' then Date({Command.closedate})
The @null is a blank formula
The manual crosstab is again showing the distinct counts of the above formulas in the group footer (grouped by {Command.priority})
With the column headers being
//@date1
date(dateadd("d",-8,CurrentDate))
and so on
My problem is I am getting different data when scheduling the report daily at the same time for the days. i.e. when ran off the report on 21/09 the calls for the 20/09 were 12,58,43,34 and 113 however when the report was ran today at the same time the calls for the 20/09 were 13,60,43,36 and 116. Please see attached.
I get the feeling I've over complicated the formulas but I can't see where the issue is....and I may have been staring at this too long!
Any help would be greatly appreciated.
Annette
I have a report which I've posted about before it is a subreport within another report. It shows the calls that were still open at the end of each day for a period of the last 8 days. It shows these by priority. i.e. High, Med, Low and calls that are on hold.
The report is selected from a command. The command is as follows:-
SELECT `opencall1`.`priority`,`opencall1`.`callref`, `opencall1`.`priority`, `opencall1`.`logdate`, `opencall1`.`closedate`, `mdis_status1`.`status_description`, `opencall1`.`cust_id`, `opencall1`.`suppgroup`, `updatedb1`.`updatetxt`,`company1`.`custom_f`,`company1`.`companyname`
FROM (`swdata`.`opencall` `opencall1` INNER JOIN `swdata`.`updatedb` `updatedb1` ON `opencall1`.`callref`=`updatedb1`.`callref`) INNER JOIN `swdata`.`mdis_status` `mdis_status1` ON `opencall1`.`status`=`mdis_status1`.`status_code` INNER JOIN `swdata`.`company` `company1` ON `opencall1`.`companyname`=`company1`.`companyname`
WHERE `opencall1`.`priority`<>'NL-MDIS SALES OFF SEND'
and (`opencall1`.`closedate`='' or
(concat(substring(`opencall1`.`closedate`,7,4),'-',substring(`opencall1`.`closedate`,4,2),'-',substring(`opencall1`.`closedate`,1,2),' ',
substring(`opencall1`.`closedate`,12,2),':',substring(`opencall1`.`closedate`,15,2),':',substring(`opencall1`.`closedate`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
) =1)
union all
SELECT 'All',`opencall1`.`callref`, `opencall1`.`priority`, `opencall1`.`logdate`, `opencall1`.`closedate`, `mdis_status1`.`status_description`, `opencall1`.`cust_id`, `opencall1`.`suppgroup`, `updatedb1`.`updatetxt`,`company1`.`custom_f`,`company1`.`companyname`
FROM (`swdata`.`opencall` `opencall1` INNER JOIN `swdata`.`updatedb` `updatedb1` ON `opencall1`.`callref`=`updatedb1`.`callref`) INNER JOIN `swdata`.`mdis_status` `mdis_status1` ON `opencall1`.`status`=`mdis_status1`.`status_code` INNER JOIN `swdata`.`company` `company1` ON `opencall1`.`companyname`=`company1`.`companyname`
WHERE `opencall1`.`priority`<>'NL-MDIS SALES OFF SEND'
and (`opencall1`.`closedate`='' or
(concat(substring(`opencall1`.`closedate`,7,4),'-',substring(`opencall1`.`closedate`,4,2),'-',substring(`opencall1`.`closedate`,1,2),' ',
substring(`opencall1`.`closedate`,12,2),':',substring(`opencall1`.`closedate`,15,2),':',substring(`opencall1`.`closedate`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
) =1)
union all
Select 'Hold',`opencall1`.`callref`, `opencall1`.`priority`, `opencall1`.`logdate`, `opencall1`.`closedate`, `mdis_status1`.`status_description`, `opencall1`.`cust_id`, `opencall1`.`suppgroup`, `updatedb1`.`updatetxt`,`company1`.`custom_f`,`company1`.`companyname`
FROM (`swdata`.`opencall` `opencall1` INNER JOIN `swdata`.`updatedb` `updatedb1` ON `opencall1`.`callref`=`updatedb1`.`callref`) INNER JOIN `swdata`.`mdis_status` `mdis_status1` ON `opencall1`.`status`=`mdis_status1`.`status_code` INNER JOIN `swdata`.`company` `company1` ON `opencall1`.`companyname`=`company1`.`companyname`
WHERE `opencall1`.`priority`<>'NL-MDIS SALES OFF SEND' and `updatedb1`.`updatetxt` like "%placed on hold%"
and (`opencall1`.`closedate`='' or
(concat(substring(`opencall1`.`closedate`,7,4),'-',substring(`opencall1`.`closedate`,4,2),'-',substring(`opencall1`.`closedate`,1,2),' ',
substring(`opencall1`.`closedate`,12,2),':',substring(`opencall1`.`closedate`,15,2),':',substring(`opencall1`.`closedate`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
) =1)
and
(concat(substring(`updatedb1`.`updatetime`,7,4),'-',substring(`updatedb1`.`updatetime`,4,2),'-',substring(`updatedb1`.`updatetime`,1,2),' ',
substring(`updatedb1`.`updatetime`,12,2),':',substring(`updatedb1`.`updatetime`,15,2),':',substring(`updatedb1`.`updatetime`,18,2))
>date_format(date_add(curdate(),interval -8 day),'%Y-%m-%d %H:%i:%S')
=1)
ORDER BY 1
The report is then a graph and a manual crosstab. The graph is on change of command.priority and then summarising Distinct count of @count1, @count2,@count3,@count4,@count5,@count6,@count7,@count8
The @count1-@count8 formulas are:-
//@count1
If {@logdate}<=dateadd("d",-8,CurrentDate)and ({Command.closedate}='' or {@Closedate}>dateadd("d",-8,CurrentDate))
then {Command.callref} else tonumber ({@@null})
up to
//@count8
If {@logdate}<=(DateAdd("d",-1,CurrentDate))and ({Command.closedate}='' or
{@Closedate}>(DateAdd("d",-1,CurrentDate)))then {Command.callref}else tonumber ({@@null})
The @logdate formula is
date({Command.logdate})
The @closedate formula is
If {Command.closedate}<>'' then Date({Command.closedate})
The @null is a blank formula
The manual crosstab is again showing the distinct counts of the above formulas in the group footer (grouped by {Command.priority})
With the column headers being
//@date1
date(dateadd("d",-8,CurrentDate))
and so on
My problem is I am getting different data when scheduling the report daily at the same time for the days. i.e. when ran off the report on 21/09 the calls for the 20/09 were 12,58,43,34 and 113 however when the report was ran today at the same time the calls for the 20/09 were 13,60,43,36 and 116. Please see attached.
I get the feeling I've over complicated the formulas but I can't see where the issue is....and I may have been staring at this too long!
Any help would be greatly appreciated.
Annette