我有下面的 Microsoft sql server 查询,我想在 MYSQL 数据库上运行。
在mysql数据库上得到以下错误:
[Err] 1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '[Incident Num],tt.name as [Ticket Type],freetext2 as [Severity], tp.name as [Pri' 附近使用正确的语法
我正在使用的 Microsoft Sql 服务器查询:
SELECT t.tn AS [Incident Num],
tt.name as [Ticket Type],
freetext2 as [Severity],
tp.name as [Priority] ts.name as [Status],
title as [Description],
create_time as [Created Timestamp],
CASE WHEN th.state_id=15 THEN
(select min(th.create_time) FROM ticket_history GROUP BY th.ticket_id,
th.state_id having th.state_id=15 ) else create_time as [Assigned to Accenture Timestamp],
(select min(create_time) FROM ticket_history group by ticket_id,state_id having state_id=4) as [In Progress Timestamp],
(select min(create_time) FROM ticket_history group by ticket_id,state_id having state_id=3)as [Restored timestamp],
(select max(create_time) FROM ticket_history group by ticket_id,state_id having state_id=2)as [Closed Timestamp],
(select DATEDIFF(mi,max(create_time,min(create_time) FROM ticket_history group by ticket_id,state_id having state_id=12) as [Total Time spent by the ticket in 'Pending at user'status],
cu.email as [Customer Name],
customer_user.email AS Assignee
FROM ticket t
JOIN ticket_type tt ON t.type_id=tt.id
JOIN ticket_Priority tp ON t.ticket_priority_id=tp.id
JOIN ticket_state ts ON t.ticket_state_id=ts.id
JOIN ticket_history th ON t.id=th.ticket_id
JOIN customer_user cu ON t.customer_id=cu.customer_id
JOIN customer_user ON t.responsible_user_id=customer_user.id
请帮我在不改变逻辑的情况下将查询语法修改为 ** MySQL**。