Crosstab SQL How to get the Column Heading Values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I've writen the following SQL in Excel using DAO:

Transform Count(ComplaintNo)
Select LevelOfComplaint
From tblComplaints
Where ResolvedStage <>'Resolved OR ResolvedStage Is Null
Group By LevelOfComplaint
PIVOT DateReceived

I copy the data from a recordset into Excel, the problem is I need to get
the values for DateReceived for the column headings. How do I do this?

Thanks
 
You would need to OpenRecordset on a query like this:
SELECT DISTINCT DateReceived
FROM tblComplaints
WHERE (ResolvedStage <>'Resolved')
OR (ResolvedStage Is Null)
ORDER BY DateReceived;

Then loop through the records to build the string to use in the PIVOT
clause.
 
Thanks Allen.

Allen Browne said:
You would need to OpenRecordset on a query like this:
SELECT DISTINCT DateReceived
FROM tblComplaints
WHERE (ResolvedStage <>'Resolved')
OR (ResolvedStage Is Null)
ORDER BY DateReceived;

Then loop through the records to build the string to use in the PIVOT
clause.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top