Getting a crosstab query to display month columns as names in the correct order

I'm querying a table of data that contains a date, consultant, client and $ value.

I want to summarise it in a table with the first column the consultant, the second the client. The remaining columns are the months. The$ value (QuoteAmount) is the value that populates the table of results.

SQL so far:

TRANSFORM Sum(qryBudgetReportBase.QuoteAmount) AS SumOfQuoteAmount
SELECT qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName
FROM qryBudgetReportBase
GROUP BY qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName
ORDER BY qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName, Month([StartDate])
PIVOT Month([StartDate]);

I've attached a shot of the results without the first two columns because they are identifiable.

Problems:

The column headers are month numbers. I need month names.

Months with no data do not appear. I need empty months.

The months are in Jan-Dec order, I need them in the order of the months from the start of the dataset, in this case July, so they should read left to right from Jul-Jun
Crosstab.JPG
snooflehammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
try

PIVOT Format([StartDate],"mmm") In ("Jul","Aug","Sep","Oct","Nov","Dec","Jan","Feb","Mar","Apr","May","Jun")

but i suggest you need to add the year in your header i.e.,  2014 Jul, 2014 Aug ....
IrogSintaCommented:
Will the dataset always start from July or does this change?
snooflehammerAuthor Commented:
Always from July, but I'll need to specify the year
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

snooflehammerAuthor Commented:
Ignore the year specification. I've already isolated the date range in the subset of data I'm working with
Rey Obrero (Capricorn1)Commented:
test this

TRANSFORM Sum(qryBudgetReportBase.QuoteAmount) AS SumOfQuoteAmount
 SELECT qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName
 FROM qryBudgetReportBase
 GROUP BY qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName
 ORDER BY qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName, Month([StartDate])
PIVOT Format([StartDate],"mmm") In ("Jul","Aug","Sep","Oct","Nov","Dec","Jan","Feb","Mar","Apr","May","Jun")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
snooflehammerAuthor Commented:
I had to modify it slightly, but it essentially did the job:

TRANSFORM Sum(qryBudgetReportBase.QuoteAmount) AS SumOfQuoteAmount
SELECT qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName
FROM qryBudgetReportBase
GROUP BY qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName
ORDER BY qryBudgetReportBase.Consultant, qryBudgetReportBase.ClientName
PIVOT Format([StartDate],"mmm") In ("Jul","Aug","Sep","Oct","Nov","Dec","Jan","Feb","Mar","Apr","May","Jun");

Thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.