Adaptive Server Anywhere 是否不支持 FROM 子句中的子查询?

发布于 2024-09-18 18:27:11 字数 356 浏览 17 评论 0原文

我正在尝试对 Adaptive Server Anywhere 数据库执行 SQL 查询。如下:

SELECT count(*) AS s
FROM (
    SELECT column1, count(*) AS n
    FROM table1
    GROUP BY column1
    HAVING n > 1
)

在子查询中,我想要获取所有重复的行,在外部查询中我想要重复的行的计数。

但每当我在 FROM 子句中使用子查询时,数据库就会显示语法错误。这是不支持的吗?

我正在 Powerbuilder 中的交互式 SQL 中执行查询。我使用 ODBC 连接到我的数据库。

I am trying to execute an SQL query on an Adaptive Server Anywhere database. Here it is:

SELECT count(*) AS s
FROM (
    SELECT column1, count(*) AS n
    FROM table1
    GROUP BY column1
    HAVING n > 1
)

In the subquery, I want to get all the rows that are duplicates and in the outer query I want a count of the rows that are duplicates.

But the database says that I have a syntax error whenever I use a subquery in the FROM clause. Is this not supported?

I am executing the query in interactive SQL in Powerbuilder. I am connected to my database using ODBC.

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

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

发布评论

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

评论(2

很酷不放纵 2024-09-25 18:27:11

我对Adaptive Server一无所知,但尝试在from语句中为子查询添加别名,如下所示:

SELECT count(*) AS s
FROM (
    SELECT column1, count(*) AS n
    FROM table1
    GROUP BY column1
    HAVING n > 1
) result -- add this

MSSQL需要这个才能工作,也许AS也需要它。

I dont know anything about Adaptive Server, but try to add alias for the subquery in from statement, like this:

SELECT count(*) AS s
FROM (
    SELECT column1, count(*) AS n
    FROM table1
    GROUP BY column1
    HAVING n > 1
) result -- add this

MSSQL needs this to work maybe AS needs it too.

最偏执的依靠 2024-09-25 18:27:11

ASA 不支持这样的“内存中”表。您将需要创建一个临时表,然后从那里提取计数。

ASA does not support "in memory" tables like this. You will need to create a temp table and then pull your count from there.

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