Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Group by error when using function

AParmJul 30 2019 — edited Jul 30 2019

Hello

This is on Oracle 12.1

I have a view as follows

create view View_Employee
as
select
Employee_No,
Department_Code,
Site_Code,
Get_Manager(Site_Code, Department_Code) Manager --this is a user defined function
from Employee

I have a simple query that uses the view as follows which groups by the column whose value is generated by the function and that works fine

select
Manager,
count(*) Employee_Count
from View_Employee
group by Manager

But it this doesn't work, does anybody know why?

select * from (
select
Manager,
count(*) Employee_Count
from View_Employee
group by Manager
)

I get error

ORA-00979: not a GROUP BY expression

This post has been answered by MihaiF on Jul 30 2019
Jump to Answer
Comments
Post Details
Added on Jul 30 2019
12 comments
780 views