使用临时列执行以下查询时出错

时间:2017-05-19 21:36:21

标签: mysql sql sql-server

我知道这看起来有点简单但我在执行此查询时遇到了这个错误:

SELECT 'NOC Service Request Acknowledgement - All severities' AS [Problem_Type_Name(Parent) Category]
,[Job_ticket_id]
,CASE WHEN (case when [Escalated to Resolved time] is null then (ISNULL([Escalated to Resolved time],0) + ISNULL([Escalated to Closed time],0)- ISNULL([hold time],0)) else (ISNULL([Escalated to Closed time],0) - ISNULL([hold time],0)) end) <0THEN 0 ELSE (case when [Escalated to Resolved time] is null then (ISNULL([Escalated to Resolved time],0) + ISNULL([Escalated to Closed time],0)- ISNULL([hold time],0)) else (ISNULL([Escalated to Closed time],0) - ISNULL([hold time],0)) end)  END AS JobTime
,[Time to Accept SLA]
,[Report_Date]
,[Problem_Type_Name(Parent)]
,[Problem_Type_Name(Child)]
,[Assigned Tech]
,[PRIORITY_TYPE_NAME]
,[Close_Date]
,[NAME]
,[Ticket Status]
,[Escalated to Closed time]
,[Escalated to Resolved time]
,[Hold Time]
,case when String_value in ('Warning' ,'Critical') then String_value else null end  as 'String_value'
,[PROBLEM_TYPE_ID]
FROM TEMP_TICKET_STATE_Category
join ticket_custom_field custom1 on custom1.entity_id = job_ticket_id
join custom_field_definition custom_definition1 on custom_definition1.id=custom1.definition_id  
WHERE [Problem_Type_Name(Parent) Category] IN ('NOC Service Request Acknowledgement - Urgent','NOC Service Request Acknowledgement - High',
'NOC Service Request Acknowledgement - Medium','NOC Service Request Acknowledgement - Low')

在此查询中,[Problem_Type_Name(父级)类别]是根据定义的条件插入故障组的列,并为其提供组名称,如“NOC服务请求确认 - 紧急”,“NOC服务请求确认” - 高','NOC服务请求确认 - 中等','NOC服务请求确认 - 低'。 我的查询似乎有问题,因为上面的代码在Where条件下给出错误。

1 个答案:

答案 0 :(得分:0)

[Problem_Type_Name(Parent)Category] ​​

不适用于

的列