簡體   English   中英

…oracle針對初學者的語法分組

[英]…oracle group by syntax for beginners

請問這是什么問題?

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

不允許將單個功能與組功能一起使用。 就像混合count與單行功能一樣。

您應該包括group by功能group by

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

當您在大多數RDBMS中執行GROUP BY時,您的選擇僅限於以下兩件事:

  • GROUP BY提到的列-在您的情況下,這是inst.type
  • 聚合函數-例如, count(inst.id)

但是,頂部的inst.id都不是其中之一。 您需要刪除它以使該語句起作用:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM