TRANSFORM and PIVOT in Access 2013 SQL

ε祈祈猫儿з 提交于 2019-12-28 02:07:15

问题


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."

Help me, please!

Thank you!


回答1:


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 



回答2:


I have found solution by myself:

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

Thanks everyone for help.



来源:https://stackoverflow.com/questions/16691853/transform-and-pivot-in-access-2013-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!