G
Guest
Hi.
I have a DB that was created by another user that I am trying to fix.
Ultimately, I need to produce a report showing monthly and fiscal year
totals. Currently, the report is showing the monthly totals, but I have no
idea how to define the FY. Our fiscal year is 1 April. 2005 to 31 March,
2006. The "report" is pulling from several different queries, including a
crosstab query that pushes all months (Jan, Feb, Mar, etc) across the top of
the page. Below is the SQL version of the query that was developed by
someone else that initially pulled the report. Below that is the SQL version
of the query I had to use that includes the incorporation of the crosstab
query.
SELECT Opportunities.TaskID, Opportunities.OQID, Opportunities.OppName,
Bookings.BusAreaID, Opportunities.Probability, DatePart("m",[BookDate]) AS
BookMonth, DatePart("yyyy",[BookDate]) AS BookYear, Bookings.BookAmount,
[BookAmount]*[Probability] AS [Weighted Bookings], Bookings.BookDate
FROM Opportunities INNER JOIN Bookings ON Opportunities.OppID = Bookings.OppID
WHERE (((DatePart("yyyy",[BookDate]))="2006") AND ((Opportunities.OppStatus)
Like "New" Or (Opportunities.OppStatus)="Potential" Or
(Opportunities.OppStatus)="Developing" Or (Opportunities.OppStatus)="Mature"
Or (Opportunities.OppStatus)="Contracting"));
BELOW IS THE ACTUAL QUERY THAT THE REPORT IS TIED TO:
SELECT [FY 2006 Forecast].OQID, [FY 2006 Forecast].OppName, [FY 2006
Forecast].BusAreaID, [FY 2006 Forecast].Probability, [FY 2006
Forecast_Crosstab1].Jan, [FY 2006 Forecast_Crosstab1].Feb, [FY 2006
Forecast_Crosstab1].Mar, [FY 2006 Forecast_Crosstab1].Apr, [FY 2006
Forecast_Crosstab1].May, [FY 2006 Forecast_Crosstab1].Jun, [FY 2006
Forecast_Crosstab1].Jul, [FY 2006 Forecast_Crosstab1].Aug, [FY 2006
Forecast_Crosstab1].Sep, [FY 2006 Forecast_Crosstab1].Oct, [FY 2006
Forecast_Crosstab1].Nov, [FY 2006 Forecast_Crosstab1].Dec, [FY 2006
Forecast].[Weighted Bookings], [FY 2006 Forecast].BookAmount, [FY 2006
Forecast_Crosstab1].[Total Of BookAmount]
FROM [FY 2006 Forecast] INNER JOIN [FY 2006 Forecast_Crosstab1] ON [FY 2006
Forecast].OppName = [FY 2006 Forecast_Crosstab1].OppName;
BELOW IS THE CROSSTAB QUERY:
TRANSFORM Sum([FY 2006 Forecast].BookAmount) AS SumOfBookAmount
SELECT [FY 2006 Forecast].OppName, Sum([FY 2006 Forecast].BookAmount) AS
[Total Of BookAmount]
FROM [FY 2006 Forecast]
GROUP BY [FY 2006 Forecast].OppName
PIVOT Format([BookDate],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
Please help. I have been working with the DB for 3 weeks now, and am hardly
making any headway.
THANK YOU!!!
I have a DB that was created by another user that I am trying to fix.
Ultimately, I need to produce a report showing monthly and fiscal year
totals. Currently, the report is showing the monthly totals, but I have no
idea how to define the FY. Our fiscal year is 1 April. 2005 to 31 March,
2006. The "report" is pulling from several different queries, including a
crosstab query that pushes all months (Jan, Feb, Mar, etc) across the top of
the page. Below is the SQL version of the query that was developed by
someone else that initially pulled the report. Below that is the SQL version
of the query I had to use that includes the incorporation of the crosstab
query.
SELECT Opportunities.TaskID, Opportunities.OQID, Opportunities.OppName,
Bookings.BusAreaID, Opportunities.Probability, DatePart("m",[BookDate]) AS
BookMonth, DatePart("yyyy",[BookDate]) AS BookYear, Bookings.BookAmount,
[BookAmount]*[Probability] AS [Weighted Bookings], Bookings.BookDate
FROM Opportunities INNER JOIN Bookings ON Opportunities.OppID = Bookings.OppID
WHERE (((DatePart("yyyy",[BookDate]))="2006") AND ((Opportunities.OppStatus)
Like "New" Or (Opportunities.OppStatus)="Potential" Or
(Opportunities.OppStatus)="Developing" Or (Opportunities.OppStatus)="Mature"
Or (Opportunities.OppStatus)="Contracting"));
BELOW IS THE ACTUAL QUERY THAT THE REPORT IS TIED TO:
SELECT [FY 2006 Forecast].OQID, [FY 2006 Forecast].OppName, [FY 2006
Forecast].BusAreaID, [FY 2006 Forecast].Probability, [FY 2006
Forecast_Crosstab1].Jan, [FY 2006 Forecast_Crosstab1].Feb, [FY 2006
Forecast_Crosstab1].Mar, [FY 2006 Forecast_Crosstab1].Apr, [FY 2006
Forecast_Crosstab1].May, [FY 2006 Forecast_Crosstab1].Jun, [FY 2006
Forecast_Crosstab1].Jul, [FY 2006 Forecast_Crosstab1].Aug, [FY 2006
Forecast_Crosstab1].Sep, [FY 2006 Forecast_Crosstab1].Oct, [FY 2006
Forecast_Crosstab1].Nov, [FY 2006 Forecast_Crosstab1].Dec, [FY 2006
Forecast].[Weighted Bookings], [FY 2006 Forecast].BookAmount, [FY 2006
Forecast_Crosstab1].[Total Of BookAmount]
FROM [FY 2006 Forecast] INNER JOIN [FY 2006 Forecast_Crosstab1] ON [FY 2006
Forecast].OppName = [FY 2006 Forecast_Crosstab1].OppName;
BELOW IS THE CROSSTAB QUERY:
TRANSFORM Sum([FY 2006 Forecast].BookAmount) AS SumOfBookAmount
SELECT [FY 2006 Forecast].OppName, Sum([FY 2006 Forecast].BookAmount) AS
[Total Of BookAmount]
FROM [FY 2006 Forecast]
GROUP BY [FY 2006 Forecast].OppName
PIVOT Format([BookDate],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
Please help. I have been working with the DB for 3 weeks now, and am hardly
making any headway.
THANK YOU!!!