解决“ORA-00937: 不是单组分组函数”报错

原SQL:
select distinct a.begin_exec_time,b.drug_code,b.drug_name,b.drug_spec,sum(b.public_retail_price*a.total_drug) as "总金额",b.public_retail_price
from ZOEPRES.PRES_INP_PRES_RECORD a,ZOEDICT.DIC_DRUG_DICT b 
where b.print_form_code=01

结果:报“ORA-00937: 不是单组分组函数”错误。

更改后SQL:

select distinct a.begin_exec_time,b.drug_code,b.drug_name,b.drug_spec,sum(b.public_retail_price*a.total_drug) as "总金额",b.public_retail_price
from ZOEPRES.PRES_INP_PRES_RECORD a, ZOEDICT.DIC_DRUG_DICT b 
where b.print_form_code=01
group by a.begin_exec_time,b.drug_code,b.drug_name,b.drug_spec,b.public_retail_price

结果:完美解决!

 

posted @ 2023-02-07 18:10  Java猿道  阅读(369)  评论(0)    收藏  举报