Pivot question

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,
I've four tables with the following fields:

Ta:
Agent_ID
Claim_Date
Claim_Cost

Tb:
Agent_ID
Agent_Name

Tc:
Agent_ID
Contract_Date
Contract_Cost

Td:
Agent_ID
Agent_Exp_Date
Agent_Exp_Cost

I need to create a query with the following information:
1. Grouping the dates per month so a yearly report can be created.
2. For each month should be applied the following formula:
SUM(CASE WHEN DATEPART(M, Tc.Contract.date) = 1 THEN Tc.Contract_Cost -
(Tc.Contract_Cost *0.10 + Ta.Claim.Cost + Td.Agent_Exp.Cost) ELSE 0 END) AS
Jan. and so on.to obtain the 12 months. Then SUM (all months per Agent) AS
TotalAnnual.

WHERE DATEPART (YYYY, all dates) = 2007

I've created tree subqyueries linking them with Agent_ID with no avail and
was wondering if someone can help me out.

TIA
Ana

SQL2K -Access 2003


--------------------------------------------------------------------------------
Estoy utilizando la versión gratuita de SPAMfighter para usuarios privados.
Ha eliminado 2958 correos spam hasta la fecha.
Los abonados no tienen este mensaje en sus correos.
¡Pruebe SPAMfighter gratis ya!


.



Relevant Pages

  • Re: Help w/pivot
    ... Dejan Sarka ... I need to create a query with the following information: ... Estoy utilizando la versión gratuita de SPAMfighter para usuarios ... Ha eliminado 2939 correos spam hasta la fecha. ...
    (microsoft.public.sqlserver.datamining)
  • Help w/pivot
    ... I need to create a query with the following information: ... Grouping the dates per month so a yearly report can be created. ... Estoy utilizando la versión gratuita de SPAMfighter para usuarios privados. ... Ha eliminado 2939 correos spam hasta la fecha. ...
    (microsoft.public.sqlserver.datamining)
  • Datediff
    ... I need to build a query which lists clients who have not placed an order for ... Estoy utilizando la versión gratuita de SPAMfighter para usuarios privados. ... Ha eliminado 2594 correos spam hasta la fecha. ...
    (microsoft.public.access.queries)
  • Re: Still probs with my code
    ... Doug Steele, Microsoft Access MVP ... possibility is that there's a problem with your References ... Estoy utilizando la versión gratuita de SPAMfighter para usuarios ... Ha eliminado 963 correos spam hasta la fecha. ...
    (microsoft.public.access.forms)
  • Re: Y/N radial option
    ... update event that you should be able to use. ... Estoy utilizando la versión gratuita de SPAMfighter para usuarios ... Ha eliminado 967 correos spam hasta la fecha. ...
    (microsoft.public.access.forms)