Sql …针对初学者的oracle语法分组

Sql …针对初学者的oracle语法分组,sql,oracle,syntax,Sql,Oracle,Syntax,请问这里面有什么问题? select inst.id , inst.type as "TypeOfInstall" , count(inst.id) as "NoOfInstall" from dm_bsl_ho.installment inst group by inst.type 不允许将单个函数与组函数一起使用。类似于混合计数和单行功能 您应该包括分组依据功能: select inst.type

请问这里面有什么问题?

select inst.id            
,      inst.type          as "TypeOfInstall"
,      count(inst.id)     as "NoOfInstall"
from   dm_bsl_ho.installment inst
group  by inst.type

不允许将单个函数与组函数一起使用。类似于混合
计数
和单行功能

您应该包括
分组依据
功能:

 select inst.type          as "TypeOfInstall"
 ,      count(inst.id)     as "NoOfInstall"
 from   dm_bsl_ho.installment inst
 GROUP BY inst.type;

在大多数RDBMS中执行
分组方式时,您的选择仅限于以下两项:

  • 组中提到的列由
    -在您的情况下,这是
    inst.type
  • 聚合函数-例如,
    count(inst.id)
但是,顶部的
inst.id
不是其中之一。您需要删除它才能使语句正常工作:

SELECT 
       type       as "TypeOfInstall"
 ,     COUNT(id)  as "NoOfInstall"
 FROM  dm_bsl_ho.installment
 GROUP BY type

显示的错误是什么?在哪里?