TRANSFORM and PIVOT in Access 2013 SQL

Viktor Krykun picture Viktor Krykun · May 22, 2013 · Viewed 51.3k times · Source

How can I get second table from first table using TRANSFORM and PIVOT functions:

TABLE_01

Config_ID  |  ConfigField  |  ConfigValue
-----------------------------------------
       11  |         Name  |        Basic
       11  |      Version  |         1.01
       11  |        Owner  |         Jack
       12  |         Name  |     Advanced
       12  |      Version  |         1.03
       12  |        Owner  |         Andy

TABLE_02

Config_ID  |      Name  |  Version  |  Owner
--------------------------------------------
       11  |     Basic  |     1.01  |  Jack
       12  |  Advanced  |     1.03  |  Andy

I'm trying this:

TRANSFORM ConfigValue
SELECT Config_ID
FROM TABLE_01
GROUP BY Config_ID
PIVOT ConfigField  

but got an error:

"Your query does not include the specified expression 'ACValue' as part of aggregate function."

Answer

Taryn picture Taryn · May 22, 2013

It looks like you are missing the aggregate function in the TRANSFORM:

TRANSFORM Max(ConfigValue)
SELECT Config_ID
FROM TABLE_01
GROUP BY Config_ID
PIVOT ConfigField