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?
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 ....
0
IrogSintaCommented:
Will the dataset always start from July or does this change?
0
snooflehammerAuthor Commented:
Always from July, but I'll need to specify the year
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

snooflehammerAuthor Commented:
Ignore the year specification. I've already isolated the date range in the subset of data I'm working with
0
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")
0

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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.