Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 718
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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