Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group by function

Status
Not open for further replies.

Kido

Programmer
Dec 10, 2001
29
KE
I want to do a report which is from different tables and I want to use the group by function e.g

select a.staff_num, sum(a.amount), b.first_name, b.last_name, c.staff_num
where ........
group by a.staff_num;

When I try to execute, I get an error message not a group by function. What could be the problem or is it that grout by function is for a single table?
 
Can you copy and paste the exact error message?

I assume that you got something like "Column 'b.first_name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." Is that right?

 
This is the script:

SELECT "EMPLOYEES"."FIRST_NAME",
"EMPLOYEES"."MIDDLE_NAME",
"EMPLOYEES"."LAST_NAME",
"EMPLOYEES"."JOB_CATEGORY",
"EMPLOYEES"."AREA",
"INVOICE_LINES"."STAFF_NUM",
"INVOICE_LINES"."AMOUNT",
"INVOICE_LINES"."LINE_TYPE",
"INVOICE_LINES"."INV_CODE"
FROM "EMPLOYEES",
"INVOICE_LINES"
WHERE ( "EMPLOYEES"."AREA" = 2060) AND
( "EMPLOYEES"."JOB_CATEGORY" NOT IN ('40') )
GROUP BY INVOICE_LINES.STAFF_NUM;

and this is the exact error:

ORA-00979: not a GROUP BY expression
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top