我在DateTime中有一列,并且像我在下面的查询中尝试的那样,需要通过SQL select查询来获取每个站点的状态。 执行查询时收到错误-“'TIMESTAMPDIFF'不是公认的内置函数名称。”
SELECT co.controllerid,
co.controllerno,
co.ControllerName,
co.SerialNo,
co.MACAddress,
c.HBLatestDateTime,
c.TrnxLatestDateTime,
'STATUS' AS STAT,
CASE
WHEN TIMESTAMPDIFF(MINUTE, c.HBLatestDateTime, GETDATE()) <= 5 THEN 'online'
WHEN (TIMESTAMPDIFF(MINUTE, c.HBLatestDateTime, GETDATE()) > 720
AND TIMESTAMPDIFF(MINUTE, c.HBLatestDateTime, GETDATE()) <= 30) THEN 'idle'
ELSE 'offline'
END AS user_status
FROM Controllers AS co
INNER JOIN Controllersruntime AS c ON c.ControllerID = co.ControllerID
AND co.Markdeleted != 1
WHERE HBLatestDateTime = CONVERT(date, GETDATE())
ORDER BY co.ControllerName ASC;
答案 0 :(得分:1)
TIMESTAMPDIFF是MySql中的一个函数,我想您想使用DATEDIFF
QUEUE_DRIVER=database