Parsing of SQL Query Failed

Parsing of SQL Query Failed

Hi,

Using MS SQL I have this query that returns records in SSMS.

But it does not work when adding the query as a SQL local data source.


  1. SELECT 
  2. qd.QUEUENAME AS 'Group',
  3. ti.FIRST_NAME AS 'Technician',
  4. count (wo.WORKORDERID) AS 'Inbound',
  5. dateadd(s,datediff(s,GETUTCDATE() ,getdate()) + (wo.createdtime/1000),'01-01-1970 00:00:00') as 'Date',
  6. count(case when (std.ispending='1') THEN 1 ELSE NULL END) 'Total Pending',
  7. count(case when (std.ispending='0') THEN 1 ELSE NULL END) 'Total Completed', 
  8. count(case when (std.statusname='OnHold') THEN 1 ELSE NULL END) 'Onhold',
  9. count(case when (std.statusname='resolved') THEN 1 ELSE NULL END) 'Resolved',
  10. count(case when (wos.ISOVERDUE='1') THEN 1 ELSE NULL END) 'SLA violated',
  11. count(case when (wos.ISOVERDUE='0') THEN 1 ELSE NULL END) 'SLA not violated',
  12. count(case when (wos.IS_FR_OVERDUE='1') THEN 1 ELSE NULL END) 'Response SLA violated',
  13. count(case when (wos.IS_FR_OVERDUE='0') THEN 1 ELSE NULL END) 'Response SLA not violated',
  14. count(case when (wos.ISFCR='1') THEN 1 ELSE NULL END) 'FCR',
  15. count(case when (wos.REOPENED='1') THEN 1 ELSE NULL END) as 'Reopened',
  16. case when count(wo.workorderid) > 0 then cast(count(case when (wos.IS_FR_OVERDUE='1') THEN 1 ELSE NULL END) *100 as float)   / cast(count(wo.workorderid) as float) else null end  'Response %  Violated',
  17. case when count(wo.workorderid) > 0 then cast(count(case when (wos.IS_FR_OVERDUE='0') THEN 1 ELSE NULL END) *100 as float)   / cast(count(wo.workorderid) as float) else null end  'Response % not Violated',
  18. case when count(wo.workorderid) > 0 then cast(count(case when (wos.ISOVERDUE='1') THEN 1 ELSE NULL END) *100 as float)   / cast(count(wo.workorderid) as float) else null end  '%  Violated',
  19. case when count(wo.workorderid) > 0 then cast(count(case when (wos.ISOVERDUE='0') THEN 1 ELSE NULL END) *100 as float)   / cast(count(wo.workorderid) as float) else null end  '% not Violated',
  20. case when count(wo.workorderid) > 0 then cast(count(case when (wos.ISFCR='1') THEN 1 ELSE NULL END) *100 as float)   / cast(count(wo.workorderid) as float) else null end  '%  FCR',
  21. case when count(wo.workorderid) > 0 then cast(count(case when (wos.REOPENED='1') THEN 1 ELSE NULL END) *100 as float)   / cast(count(wo.workorderid) as float) else null end  '%  Reopened'
  22. FROM WorkOrder wo
  23. LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID 
  24. LEFT JOIN SDUser td ON wos.OWNERID=td.USERID LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID  
  25. LEFT JOIN StatusDefinition std on wos.statusid=std.statusid 
  26. LEFT JOIN WorkOrder_Queue woq ON wo.WORKORDERID=woq.WORKORDERID LEFT JOIN QueueDefinition qd ON woq.QUEUEID=qd.QUEUEID 
  27. WHERE (wo.ISPARENT='1')  AND qd.QUEUENAME <> 'NULL' AND ti.FIRST_NAME <> 'NULL'
  28. --and wo.createdtime >= <from_lastmonth> and wo.createdtime <= <to_lastmonth>    
  29. GROUP BY Qd.QUEUENAME, ti.FIRST_NAME, Wo.CREATEDTIME
  30. order by 1


Problem is in when I create a new data source then add the same query I get the error "Parsing of SQL Query Failed"




How can I get this to work?

                New to ADSelfService Plus?