Q:

Access 2007 - 'rotating' data without using a crosstab query

I have a query that returns data like this:
Store    Product    CasesPerStore
Bob's    Original       2
Bob's    Super          1
Tom's    Original       5
Pete's   Original       9
Pete's   Super          2

And I want to join it to another query by Store, to end up with this:
Other query headings....       Store    Original CasesPerStore    Super CasesPerStore
Other query data........       Bob's             2                        1
Other query data........       Tom's             5
Other query data........       Pete's            9                        2

I can do this to the original data using a crosstab query, but I then can't reference the new crosstab headings (e.g. [Original CasesPerStore] and [Super CasesPerStore]) in a join, probably because they are dynamic i.e. the headings could change depending on what products are in the data at that point.
So how can I join to this 'rotated' data?

A:

If you know in advance how many products there are, and they are permanently fixed, then this simplistic solution may be enough. By using Iif statements you can get around the pivoting of data but it's hard-coded SQL.
SELECT tbl.Store,
   SUM(Iif([Product] = "Original", [CasesPerStore], 0)) AS [Original CasesPerStore],
   SUM(Iif([Product] = "Original", 0, [CasesPerStore])) AS [Super CasesperStore]
FROM   tbl
GROUP  BY tbl.Store

