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!

Problem with AVG function

Status
Not open for further replies.

egstatus

Programmer
Apr 14, 2005
143
US
Hi,
I have a problem with the following query. It is returning the same average for each record.
What I'm trying to do is to calculate the average by each positions within the company.

Here is my code:
SQL:
SELECT B.CORR_PUESTO, B.NOMBRE_PUESTO,  AVG(A.MONTO_NETO) AS AVERAGE_MONTO_NETO
FROM PLA_DOCUMENTO_DETA AS A
INNER JOIN PLA_PUESTO AS B ON A.CORR_EMPRESA = B.CORR_EMPRESA
WHERE A.CORR_EMPRESA = 1 
GROUP BY B.CORR_PUESTO, B.NOMBRE_PUESTO
ORDER BY AVERAGE_MONTO_NETO DESC

Here is part of the result it returns:
Code:
CORR_PUESTO	NOMBRE_PUESTO	AVERAGE_MONTO_NETO
0		393.454
1	Asistente de Gerencia	393.454
2	Contador	393.454
3	Supervisor de Proyectos	393.454
4	Mensajero	393.454
5	Negociador de Sitios	393.454
6	Aux. Contable	393.454
7	Ingeniero de Proyectos	393.454
8	Aux. Legal	393.454
9	Abogado	393.454
10	Seguridad	393.454
11	Jefe de Seguridad	393.454
12	Ordenanza	393.454
13	Ejecutiva de Ventas	393.454
14	Tecnico de Mantenimiento	393.454
15	Informatica	393.454
16	Recepcionista	393.454
17	Tecnico Ingeniero	393.454
18	Seguridad / Motorista	393.454
19	Aux. Administrativo	393.454

I know for a fact that these positions have different amounts per each period [each period = 2 weeks]
I don't understand why I keep getting the same average for each of the positions.

Any help would be greatly appreciated.

Thanks
EG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top