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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

union query error 1

Status
Not open for further replies.

vz

MIS
Jul 31, 2001
131
US
does anyone know what i am doing wrong i keep gettting an aggregate function error related to the field name:

SELECT qryAllReportEntryProblemsIncluding501s.[SubmittedBy] as Name, qryAllReportEntryProblemsIncluding501s.[DateEntered] From qryAllReportEntryProblemsIncluding501s
UNION ALL Select qryAllReportEntryProblemsIncluding501s.[Reviewer] as Name, qryAllReportEntryProblemsIncluding501s.[DateEntered] from qryAllReportEntryProblemsIncluding501s
GROUP BY qryAllReportEntryProblemsIncluding501s.[DateEntered];

thanks
 
Your group by clause needs to contain all columns that do not have aggregates in them. You might try to add the name column to your group by and see if that corrects the problem.
 
I tried that but it didn't work it said tat name since i create it isn't a field. This is what i have:
SELECT qryAllReportEntryProblemsIncluding501s.[SubmittedBy] as Name, qryAllReportEntryProblemsIncluding501s.[DateEntered] From qryAllReportEntryProblemsIncluding501s
UNION ALL Select qryAllReportEntryProblemsIncluding501s.[Reviewer] as Name, qryAllReportEntryProblemsIncluding501s.[DateEntered] from qryAllReportEntryProblemsIncluding501s
ORDER BY qryAllReportEntryProblemsIncluding501s.[Name], qryAllReportEntryProblemsIncluding501s.[DateEntered];

thanks
 
I apologize. You can only use the Group By clause in each of the seperate Select statements in the Union Query. You can use the Order By at the end of the entire Union query. You might try:


SELECT qryAllReportEntryProblemsIncluding501s.[SubmittedBy] as Name, qryAllReportEntryProblemsIncluding501s.[DateEntered] From qryAllReportEntryProblemsIncluding501s
Group By qryAllReportEntryProblemsIncluding501s.[SubmittedBy], qryAllReportEntryProblemsIncluding501s.[DateEntered]
UNION ALL Select qryAllReportEntryProblemsIncluding501s.[Reviewer] as Name, qryAllReportEntryProblemsIncluding501s.[DateEntered] from qryAllReportEntryProblemsIncluding501s
GROUP BY qryAllReportEntryProblemsIncluding501s.[Reviewer], qryAllReportEntryProblemsIncluding501s.[DateEntered]
Order By Name, DateEntered;


I think that might work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top