Page 1 of 1

SQL HELP

Posted: Tue Feb 13, 2007 11:46 am
by Gen
this is my code

Code: Select all

SELECT HH.NumCaso, Proyectos.NameProy, Empleados.Lastname, Empleados.Name, HH.Date, Sum(HH!Hours) AS [Hours by Year], Sum(HH!Valorhh*HH!Hours) AS [Total valor anual], HH.Cargo
FROM Proyectos INNER JOIN (Empleados INNER JOIN HH ON Empleados.IdEmpleados = HH.IdEmpleados) ON Proyectos.NumCaso = HH.NumCaso
GROUP BY HH.NumCaso, Proyectos.NombreProy, Empleados.Lastname, Empleados.Name, HH.Date, HH.Cargo;
Date (dd/mm/yyyy)
I need to show the info like this:

NumCaso=187
NombreProy=Welfare
Lastname=Smith
Name=John
Year=2007
Hours by Year=400 ( summatory of hours on year 2007 by john smith in the welfare proyect)
Valorhh=10

187 Welfare Smith John 2007 400 4000


I need it on Access

and I have another problem

with the same bd, another question:
187 Welfare jan feb march april may jun july aug sept oct nov dec 2007
Smith John 100 70 60 20 30 50 50 20 0 0 0 0 400

Posted: Tue Feb 13, 2007 3:00 pm
by Gen

Code: Select all

TRANSFORM Sum(HH!Horas) AS [Horas por Años]
SELECT HH.NumCaso, Proyectos.NombreProy, Empleados.Apellidos, Empleados.Nombre, HH.Cargo, HH.Fecha, Sum(HH!Horas) AS [Horas por Año], Sum(HH!Valorhh*HH!Horas) AS [Total valor anual]
FROM Proyectos INNER JOIN (Empleados INNER JOIN HH ON Empleados.IdEmpleados=HH.IdEmpleados) ON Proyectos.NumCaso=HH.NumCaso
GROUP BY HH.NumCaso, Proyectos.NombreProy, Empleados.Apellidos, Empleados.Nombre, HH.Cargo, HH.Fecha
PIVOT Format([Fecha],"mmm") In ("Ene","Feb","Mar","Abr","May","Jun","Jul","Ago"," Sep","Oct","Nov","Dic");
with this the info is sortted like this:

me acerco pero lo veo asi:
1297 32Cores lobos yamna secretaria 01/04/2007 2 50000_1
1297 32Cores lobos yamna secretaria 01/05/2007 2 50000__5
1297 32Cores lobos yamna secretaria 01/06/2007 2 50000___8
1297 32Cores lobos yamna secretaria 01/07/2007 2 50000____4
1297 32Cores lobos yamna secretaria 01/08/2007 2 50000_____19

and I need this
1297 32Cores lobos yamna secretaria 2007 10 500000 1 5 8 4 19