Help to create this crosstab query

M

Marco

Hi. I need help to create this crosstab query.

I've got my actual query like this: (Rows)
ID DInicio DFim
3000 38279 38340
3000 38353 38561
3000 38578 38927

and I need to make it look like this: (one reocord, column)
ID DInicio DFim DInicio DFim DInicio DFim
3000 38279 38340 38353 38561 38578 38927


Please help me out here.

Regards in advance.
Marco
 
D

Duane Hookom

You can't generate multiple columns with the same name. You would need to
generate a column/value for each record that would create a sequence/ranking
of for 1 to 3 (since you have 3 records). Then, I would create a union query
like:

SELECT ID, Rank, "DInicio" as ColHead, DInicio as TheValue
FROM queryWithRank
UNION ALL
SELECT ID, Rank, "Dfim", DFim
FROM queryWithRank;

Then create a crosstab based on the union query with ID as the Row Heading,
First Of TheValue as the Value, and ColHead & Rank as the Column Heading.
 

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

Similar Threads


Top