I have an Access database that looks something like this:
ID | TestDate | Test1 | Test2 | Test 3 |
1 | Date1 | 10 | 20 |
How about:
TRANSFORM SUM(q.testval) AS sumoftestval
SELECT q.id,
q.test
FROM (SELECT t2.id,
t2.testdate,
"test1" AS Test,
t2.test1 AS TestVal
FROM t2
UNION ALL
SELECT t2.id,
t2.testdate,
"test2" AS Test,
t2.test2 AS TestVal
FROM t2
UNION ALL
SELECT t2.id,
t2.testdate,
"test3" AS Test,
t2.test3 AS TestVal
FROM t2) AS q
GROUP BY q.id,
q.test
PIVOT q.testdate;
Select an ID
TRANSFORM Sum(q.testval) AS sumoftestval
SELECT q.test
FROM (SELECT t2.id,
t2.testdate,
"test1" AS Test,
t2.test1 AS TestVal
FROM t2
UNION ALL
SELECT t2.id,
t2.testdate,
"test2" AS Test,
t2.test2 AS TestVal
FROM t2
UNION ALL
SELECT t2.id,
t2.testdate,
"test3" AS Test,
t2.test3 AS TestVal
FROM t2) AS q
WHERE q.id=1
GROUP BY q.test
PIVOT q.testdate;