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

Another Union Query Question 2

Status
Not open for further replies.

ecugrad

MIS
Apr 17, 2001
191
US
In the below Union query, I'm trying to set the number of decimal places to 2 on Score field. What do I need to add to the query to do this?

Thanks again..

Mike

I'm using Acess 2003

SELECT [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department, Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]) AS Score
FROM ([R&R_PhoneAssessment] INNER JOIN [R&R_Employees] ON [R&R_PhoneAssessment].Agent = [R&R_Employees].EmployeeID) INNER JOIN [R&R_Departments] ON [R&R_Employees].Department = [R&R_Departments].Department
WHERE ((([R&R_PhoneAssessment].CallDate)>=#4/1/2006# And ([R&R_PhoneAssessment].CallDate)<=#4/30/2006#) AND (([R&R_PhoneAssessment].Auditor)=1))
GROUP BY [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department
ORDER BY [R&R_Employees].EmployeeID;
UNION SELECT [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department, Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]) AS Score
FROM ([R&R_OutBoundPhoneAssessment] INNER JOIN [R&R_Employees] ON [R&R_OutBoundPhoneAssessment].Agent = [R&R_Employees].EmployeeID) INNER JOIN [R&R_Departments] ON [R&R_Employees].Department = [R&R_Departments].Department
WHERE ((([R&R_OutBoundPhoneAssessment].CallDate)>=#4/1/2006# And ([R&R_OutBoundPhoneAssessment].CallDate)<=#4/30/2006#) AND (([R&R_OutBoundPhoneAssessment].Auditor)=1))
GROUP BY [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department
ORDER BY [R&R_Employees].EmployeeID;
 
Wrap your AVG calculation in
Code:
Val(Format(AVG(...),"0.00"))
or
Code:
Round(AVG(...),2)

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Golum, what I'm I doing wroung on the below? I'm getting an error message..

Thanks

SELECT [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department, Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]) AS Round(AVG(Score),2)



FROM ([R&R_PhoneAssessment] INNER JOIN [R&R_Employees] ON [R&R_PhoneAssessment].Agent = [R&R_Employees].EmployeeID) INNER JOIN [R&R_Departments] ON [R&R_Employees].Department = [R&R_Departments].Department
WHERE ((([R&R_PhoneAssessment].CallDate)>=#4/1/2006# And ([R&R_PhoneAssessment].CallDate)<=#4/30/2006#) AND (([R&R_PhoneAssessment].Auditor)="1"))
GROUP BY [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department
ORDER BY [R&R_Employees].EmployeeID;
UNION SELECT [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department, Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]) AS Score
FROM ([R&R_OutBoundPhoneAssessment] INNER JOIN [R&R_Employees] ON [R&R_OutBoundPhoneAssessment].Agent = [R&R_Employees].EmployeeID) INNER JOIN [R&R_Departments] ON [R&R_Employees].Department = [R&R_Departments].Department
WHERE ((([R&R_OutBoundPhoneAssessment].CallDate)>=#4/1/2006# And ([R&R_OutBoundPhoneAssessment].CallDate)<=#4/30/2006#) AND (([R&R_OutBoundPhoneAssessment].Auditor)="1"))
GROUP BY [R&R_Employees].EmployeeID, [R&R_Employees].BNumber, [R&R_Departments].DepartmentID, [R&R_Departments].Department
ORDER BY [R&R_Employees].EmployeeID;
 
Select statement includes a reserved word or an argument that is misspelled or missing, or the punctuation uis incorrect..
 
This
Code:
Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]) AS Round(AVG(Score),2)
should be
Code:
Round(Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]), 2) AS [Score]



[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
this line is incorrect:

Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]) AS Round(AVG(Score),2)

Access thinks you are trying to use Round as an alias for this calculation.

I think you want:

ROUND(Avg([GreetScore]+([ClientScore]*10)+([AccruacyScore]*8)+[ClosingScore]), 2) As Score

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top