Help to create this crosstab query

  • Thread starter Thread starter Marco
  • Start date Start date
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
 
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.
 
Back
Top