Access 2013 SQL 中的 TRANSFORM 和 PIVOT
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16691853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TRANSFORM and PIVOT in Access 2013 SQL
提问by Viktor Krykun
How can I get second table from first table using TRANSFORM and PIVOT functions:
如何使用 TRANSFORM 和 PIVOT 函数从第一个表中获取第二个表:
TABLE_01
TABLE_01
Config_ID | ConfigField | ConfigValue
-----------------------------------------
11 | Name | Basic
11 | Version | 1.01
11 | Owner | Hyman
12 | Name | Advanced
12 | Version | 1.03
12 | Owner | Andy
TABLE_02
TABLE_02
Config_ID | Name | Version | Owner
--------------------------------------------
11 | Basic | 1.01 | Hyman
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."
“您的查询不包括指定的表达式 'ACValue' 作为聚合函数的一部分。”
采纳答案by Viktor Krykun
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.
谢谢大家的帮助。
回答by Taryn
It looks like you are missing the aggregate function in the TRANSFORM:
看起来您缺少 TRANSFORM 中的聚合函数:
TRANSFORM Max(ConfigValue)
SELECT Config_ID
FROM TABLE_01
GROUP BY Config_ID
PIVOT ConfigField