title: Access Union/Pivot to Swap Columns and Rows
body: <p>Access 2010 here. I have a query (Thank you Andomar!):</p>
  
  <pre><code>SELECT Inspection.Date, count(*) AS [# Insp], sum(iif(Disposition = 'PASS',1,0)) AS [# Passed], sum(iif(Disposition = 'FAIL',1,0)) AS [# Failed], sum(iif(Disposition = 'PASS',1,0)) /  count(*) AS [% Acceptance]
  FROM Inspection
  WHERE Disposition in ('PASS', 'FAIL') AND ((Inspection.Date) Between Date() And Date()-30)
  GROUP BY Date;
  </code></pre>
  
  <p>That gives a table like this:</p>
  
  <pre><code>Date       | # Insp | # Passed | # Failed | % Acceptance
  11/26/2012 | 7      | 5        | 2        | 71 
  11/27/2012 | 8      | 4        | 4        | 50 
  ...
  </code></pre>
  
  <p>I am looking to use this query to make a "table" for a sub-form that will be below a graph, for reference only. The formatting of the "table" is of importance, as it needs both Column (Date) and Row headings. I have table in parentheis to emphasize that the table is generated in real time; in other words, not stored as an Access object.</p>
  
  <p>The end result will be someting like this:</p>
  
  <pre><code>Date         | 11/26/2012 | 11/27/2012 ...
  # Insp       | 7          | 8
  # Passed     | 5          | 4
  # Failed     | 2          | 4
  % Acceptance | 71         | 50
  </code></pre>
  
  <p>It seems to be an optimal case, as the axis are just flipped, but for the life of me, I cannot find a solution that does not destroy the data. A Crosstab Query only gave me filtering on one or more categories against a single value. Is this something a union would be used for; or a pivot? Would a transform be needed? It seems like it should be such a simple problem. Is this something that can be done in SQL or would VBA be needed to arrange the "table?" Thanks for the help!</p>
  
  <p>These links do seem applicable:</p>
  
  <p><a href="https://stackoverflow.com/questions/9183764/columns-to-rows-in-ms-access">Columns to Rows in MS Access</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2905968/how-to-pivot-rows-to-columns">how to pivot rows to columns</a></p>