
Originally Posted by
June7
A UNION query:
SELECT "12AM" AS MyTime, Sum(IIf([Site]="A",[12AM],0)) AS [A], SUM(IIf([Site]="B" Or [Site]="C",[12AM],0)) AS [B_C] FROM table1
UN ION SELECT "1AM", Sum(IIf([Site]="A",[1AM],0)), SUM(IIf([Site]="B" Or [Site]="C",[1AM],0)) FROM table1
... ;
There is no query builder or wizard for UNION, must type in SQL View. There is a limit of 50 SELECT statements.
Or build the UNION with raw data (no aggregate calcs) which essentially produces the normalized structure data should have been in first place. Then use the UNION in subsequent queries to do calcs or as report RecordSource.
SELECT Site, "12AM" AS MyTime, [12AM] AS Data FROM table1
UN ION SELECT Site, "1AM", [1AM] FROM table1
... ;
So there really is no need for Table2 unless the goal is to normalize the data structure and this manipulation is a one-time event.