Display query date 'horizontally'

G

Guest

Hi there,
I hope someone can help me with this. I've got a query pulling data from two
related tables - tblParcels and tblTask. One Task has many Parcels. This
query displays data like this:

Task Parcel
001 123242
001 343254
001 353532
002 454543
002 535343

What I want to do is have it display like this:

Task Parcel1 Parcel2 Parcel3 Parcel4
001 123242 343254

Hope someone can help!
Andy, UK
 
G

Guest

Here is something that might work for you - uses two queries.
SELECT T.Task, T.Parcel, (SELECT COUNT(*)
FROM [AndyC] T1
WHERE T1.Task = T.Task
AND T1.X <= T.X) AS Rank INTO AndyC_Rank
FROM AndyC AS T
ORDER BY T.Task, T.Parcel;

TRANSFORM First(AndyC_Rank.Parcel) AS FirstOfx
SELECT AndyC_Rank.Task
FROM AndyC_Rank
GROUP BY AndyC_Rank.Task
PIVOT "Parcel " & [Rank];
 

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

Top