sqlite子查询语法错误

发布于 2024-09-25 04:32:09 字数 199 浏览 2 评论 0原文

我在这个子查询中有一个语法错误,我似乎无法弄清楚为什么它不起作用。所有括号都匹配

select min(max_s) 
from 
(select max(salary) from instructor group by dept_name) 
as s(max_s);

Error: near "(": syntax error

I have a syntax error in this subquery that I cannot seem to figure out why it won't work. All the parens are matched

select min(max_s) 
from 
(select max(salary) from instructor group by dept_name) 
as s(max_s);

Error: near "(": syntax error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灰色世界里的红玫瑰 2024-10-02 04:32:09

使用:

SELECT MIN(x.max_s) 
  FROM (SELECT MAX(i.salary) AS max_s 
          FROM INSTRUCTOR i
      GROUP BY i.dept_name) x

Use:

SELECT MIN(x.max_s) 
  FROM (SELECT MAX(i.salary) AS max_s 
          FROM INSTRUCTOR i
      GROUP BY i.dept_name) x
彩虹直至黑白 2024-10-02 04:32:09

问题出在 AS s(max_s) 表别名中,它看起来不太正确。您应该为子查询中的列名称添加别名,例如:

select min(s.max_s) 
from 
(select max(salary) as max_s from instructor group by dept_name) 
as s

The problem is in the AS s(max_s) table alias, which doesn't look quite right. You should alias the column name inside the subquery, for example:

select min(s.max_s) 
from 
(select max(salary) as max_s from instructor group by dept_name) 
as s
宛菡 2024-10-02 04:32:09

不要在表别名后面加上括号。

Don't put parens after a table alias.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文