• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • Last Modified:

oracle: not a single-group group function

hi guys

I do

select id, to_char(SUM(salary),'999,999,999,999') as salary from customer .

customer table has
id salary


I get error
ORA-00937: not a single-group group function
00937. 00000 -  "not a single-group group function"
*Cause:    
*Action:

any idea? Am i missing GROUP BY clause ? not sure if i need one.

thanks
0
royjayd
Asked:
royjayd
3 Solutions
 
käµfm³d 👽Commented:
Because you are selecting two columns--where one is an aggregate column, yes, you need a GROUP BY. GROUP BY the id column.
0
 
flow01Commented:
No , you can create a total  on the whole set of records without a group by clause, but
you will have to omit the  "id" because that's the value of a single record.

If you want the total salary by id ,your have to add a corresponding group by clause
0
 
Aaron ShiloChief Database ArchitectCommented:
select id, to_char(SUM(salary),'999,999,999,999') as salary
from customer
group by ID;
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now