Hi,
I've been trying to update our Monthly KPI report, along with a Last Monthly KPI report that I created.
Unfortunately the report as it stands is combining the current months totals with last years totals for the same month, so I've been trying to fix that.
Here's the Query that I've been using, but all I receive is an ajax error:
select count(wo.WORKORDERID) 'Total',
(select count(wo.WORKORDERID)
from WorkOrder wo left join WorkOrderStates wos on wo.WORKORDERID=wos.WORKORDERID left join WorkOrder_Threaded wot on wo.WORKORDERID=wot.WORKORDERID
where wot.WORKORDERID=wot.THD_WOID and wos.STATUSID=1 and (wo.CREATEDTIME >= <from_thismonth>) and (wo.CREATEDTIME <= <to_thismonth>)) 'Open',
(select count(wo.WORKORDERID)
from WorkOrder wo left join WorkOrderStates wos on wo.WORKORDERID=wos.WORKORDERID left join WorkOrder_Threaded wot on wo.WORKORDERID=wot.WORKORDERID
where wot.WORKORDERID=wot.THD_WOID and wos.STATUSID=3 and (wo.CREATEDTIME >= <from_thismonth>) and (wo.CREATEDTIME <= <to_thismonth>)) 'Closed',
(select count(wo.WORKORDERID)
from WorkOrder wo left join WorkOrderStates wos on wo.WORKORDERID=wos.WORKORDERID left join WorkOrder_Threaded wot on wo.WORKORDERID=wot.WORKORDERID
where wot.WORKORDERID=wot.THD_WOID and wos.STATUSID=3 and wo.COMPLETEDTIME > wo.DUEBYTIME and (wo.CREATEDTIME >= <from_thismonth>) and (wo.CREATEDTIME <= <to_thismonth>)) 'Not met SLA',
(select count(wo.WORKORDERID)
from WorkOrder wo left join WorkOrderStates wos on wo.WORKORDERID=wos.WORKORDERID left join WorkOrder_Threaded wot on wo.WORKORDERID=wot.WORKORDERID
where wot.WORKORDERID=wot.THD_WOID and wos.STATUSID=3 and wo.COMPLETEDTIME < wo.DUEBYTIME and (wo.CREATEDTIME >= <from_thismonth>) and (wo.CREATEDTIME <= <to_thismonth>)) 'Closed within SLA'
from WorkOrder wo left join WorkOrderStates wos on wo.WORKORDERID=wos.WORKORDERID left join WorkOrder_Threaded wot on wo.WORKORDERID=wot.WORKORDERID
where wot.WORKORDERID=wot.THD_WOID and (wo.CREATEDTIME >= <from_thismonth>) and (wo.CREATEDTIME <= <to_thismonth>))
The error is:
I can't see anything wrong with the query (I've checked all the brackets etc.), so I have no idea what's going wrong.
Cheers, Richard