SQL COUNT-不是单组组函数错误
SQL COUNT- not a single group group function error
我 运行 在 Oracle DB
上进行以下 COUNT(*)
查询:
select count(*) + (select count(*) from t_diagram) from t_object
我收到以下错误:
Not a single group- group function.
我了解使用聚合方法(例如 SUM
、AVG
)需要 GROUP BY
语句。
但是,如何在 select COUNT (*)
查询中添加 GROUP BY
?
另一个挑战:我 运行 查询的应用程序不支持 DUAL。它仅支持 SELECT 语句。有什么想法吗?
您可以改写为:
select (select count(*) from t_object) + (select count(*) from t_diagram) from dual
使用派生的table?
select sum(cnt)
from
(
select count(*) as cnt from t_object
union all
select count(*) as cnt from t_diagram
) dt
我 运行 在 Oracle DB
上进行以下 COUNT(*)
查询:
select count(*) + (select count(*) from t_diagram) from t_object
我收到以下错误:
Not a single group- group function.
我了解使用聚合方法(例如 SUM
、AVG
)需要 GROUP BY
语句。
但是,如何在 select COUNT (*)
查询中添加 GROUP BY
?
另一个挑战:我 运行 查询的应用程序不支持 DUAL。它仅支持 SELECT 语句。有什么想法吗?
您可以改写为:
select (select count(*) from t_object) + (select count(*) from t_diagram) from dual
使用派生的table?
select sum(cnt)
from
(
select count(*) as cnt from t_object
union all
select count(*) as cnt from t_diagram
) dt