为什么我的SQL查询无法显示其输出 [英] Why my SQL query fails to display its output
本文介绍了为什么我的SQL查询无法显示其输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with top_5_rows as (
select queue_name,jobs_pending,jobs_running
fr' at line 1
我的尝试:
What I have tried:
<pre>with top_5_rows as (
select queue_name,jobs_pending,jobs_running
from queues order by jobs_pending+jobs_running desc limit 5
)
select coalesce(top_5_rows.queue_name,'others'),
sum(queues.jobs_tpending) as jobs_pending,
sum(queues.jobs_running) as jobs_running
from queues
left outer join top_5_rows on
top_5_rows.queue_name = queues.queue_name
group by top_5_rows.queue_name
order by case when top_5_rows.queue_name is not null then queuename else 'zzzzz' end;
推荐答案
可能是+
的标志。试试
It is probably the+
sign. Try
with top_5_rows as (
select queue_name,jobs_pending,jobs_running
from queues order by jobs_pending, jobs_running desc limit 5
)
请参阅 MySQL :: MySQL 5.7参考手册:: 9.2.1.13 ORDER BY优化 [ ^ ]。
MySQL 没有 WITH
子句。请改用子查询: MySQL :: MySQL 5.7参考手册:: 14.2.10子查询语法 [ ^ ]
[/ EDIT]
See MySQL :: MySQL 5.7 Reference Manual :: 9.2.1.13 ORDER BY Optimization[^].
MySQL has no WITH
clause. Use a subquery instead: MySQL :: MySQL 5.7 Reference Manual :: 14.2.10 Subquery Syntax[^]
[/EDIT]
这篇关于为什么我的SQL查询无法显示其输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文