CASE Statement

Portucale

Registered User.
Local time
Today, 23:04
Joined
Sep 7, 2012
Messages
32
Hi,

A bit I a muddle with a particular query that I am trying to build. Have a table with data from 12 months and want to build a query which would give me the results for the last 6 months in separate fields (columns), I understand that in T-SQL we can build CASE Statement but seems that is not working in access so I am getting frustrated so any help is very much appreciated.

The Query to give the OVERALL results is built as follows:
SELECT
Tbl_Advisor.SKG,
Tbl_SKG.Value_Grp,
Sum(Tbl_Advisor.NetRevenue) AS NetRevenue,
Sum(Tbl_Advisor.Calls) AS Calls,
NetRevenue/Calls AS CallAverage
FROM Tbl_Advisor INNER JOIN Tbl_SKG ON Tbl_Advisor.SKG = Tbl_SKG.SkillGroup
GROUP BY
Tbl_Advisor.SKG,
Tbl_SKG.Value_Grp;

Now I want to build a query which would give me the last 6 months results for the Tbl_Advisor.SKG and Tbl_SKG.Value_Grp, results being the sum of Sum(Tbl_Advisor.NetRevenue) AS NetRevenue and Sum(Tbl_Advisor.Calls) AS Calls, finally to give the average with function (NetRevenue/Calls AS CallAverage)
I understand that I can use the function DateAdd to achieve the desired month as “DATEADD(m,-1,Max(Tbl_Advisor.Month)) AS Month_1”, but again not sure how to build the different columns…

Thanks in advance
 

Users who are viewing this thread

Back
Top Bottom