If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Not Part of an Aggregate Function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-21-11, 17:48
jbedson jbedson is offline
Registered User
 
Join Date: Dec 2009
Posts: 46
Not Part of an Aggregate Function

Sorry for the nube question. I have two tables. One for employee profiles and one for employee performance stats. Each employee's performance is rated on the group they are in. In this case thier productivity type or EmpProdType in the profile table.

Im writing a query for a report that shows the date, employee name, calls in, calls out, tickets opened, Tickets closed, and the productivity from the performance table.

In the report, I need to group the employees by EmpProdType(group) and sort by productivity, decending.

Here is query that I'm trying to use.

SELECT Emp_Stats_Daily.Perf_Daily_Date, Emp_Stats_Daily.Perf_Daily_Name, Emp_Stats_Daily.Perf_Daily_CallIn, Emp_Stats_Daily.Perf_Daily_CallOut, Emp_Stats_Daily.Perf_Daily_TicksOpen, Emp_Stats_Daily.Perf_Daily_TicksClose, Emp_Stats_Daily.Perf_Daily_Prod, Emp_Profile.EmpProdType

FROM Emp_Stats_Daily INNER JOIN Emp_Profile ON Emp_Stats_Daily.EmpID = Emp_Profile.EmpID

WHERE (((Emp_Stats_Daily.[Perf_Daily_Date])=(Select ParamValue from ParamTable where ParamName = "SelectedDate")))

GROUP BY Emp_Profile.EmpProdType
ORDER BY Emp_Stats_Daily.[Perf_Daily_Prod] DESC;

When I run this I get an error saying:
"You tried to execute a query that does not include 'Perf_Daily_Date' as part of an aggrogate function"
When I add it to the GROUP BY, it says the same thing for Perf_Daily_Name.

What am I doing wrong??

P.S. The ParamTable is an unfortunate result of using C# Express and MS Access for reporting.

Thanks for you time
Jim
Reply With Quote
  #2 (permalink)  
Old 02-21-11, 18:53
jbedson jbedson is offline
Registered User
 
Join Date: Dec 2009
Posts: 46
I figured it out..
I removed the GROUP BY and added the extra field to the SORT BY statement.

Problem solved
Reply With Quote
  #3 (permalink)  
Old 02-22-11, 02:22
JarlH JarlH is offline
Registered User
 
Join Date: Dec 2008
Location: At work...
Posts: 68
The general GROUP BY rule is:
If a GROUP BY clause is specified, each column reference in the SELECT list must either identify a grouping column or be the argument of a set function.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On