我在MS Access中有一个ODBC源表。它看起来像:
submit_time | field_order | form_name | field_name | field_value | file xxxxxxxx 0 Registration from_email xx@hotmail.com xxxxxxxx 1 Registration name_to Webmaster xxxxxxxx 2 Registration from_name xxxx xxxx xxxxxxxx 2 Registration alternative-1 selected
等.....
我一直试图把它变成这个:
submit_time | from_name | from_email | Alternative-1 | xxxxxxxx xxxx xxxx xx@hotmail.com selected xxxxxxxx xxxx xxxx xx@gmail.com
现在,我尝试使用以下代码:
select
max(case WHEN field_name = 'submit_time' then field_value end) submit_time,
max(case when field_name = 'from_name' then field_value end) from_name,
max(case when field_name = 'from_email' then field_value end) from_email
from wp_cf7dbplugin_submits
但是我得到了经典的“语法错误,缺少运算符”符号。我缺少什么想法?
答案 0 :(得分:0)
在Access中,这是通过“交叉表查询”完成的。试试这样的事情
TRANSFORM First(field_value) AS FirstOffield_value
SELECT submit_time
FROM wp_cf7dbplugin_submits
GROUP BY submit_time
PIVOT field_name