A
Ana
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
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