我有一张Excel格式report
格式如下:
+----------+--------+-------------+
| file | column | columnIndex |
+----------+--------+-------------+
| abc.xlsx | test | 14 |
| def.xlsx | test | 55 |
| abc.xlsx | xyz | 19 |
| def.xlsx | xyz | 19 |
+----------+--------+-------------+
我尝试使用ADODB进行查询,以便在column
不为空的情况下获取columnIndex
和column
值的唯一对。
我尝试了各种查询,但每个查询都给了我一个错误。
SELECT [report$].column,[report$].columnIndex
from [report$] group by [report$].column,[report$].columnIndex
having [report$].column<>''
ORDER BY columnIndex
给出了这个错误:
No value given for one or more required parameters.
此查询:
select [report$].column,[report$].columnIndex
from [report$] group by [report$].column,[report$].columnIndex
where [report$].column<>''
order by columnIndex
给出了这个错误:
Syntax error (missing operator) in query expression '[report$].columnIndex where [report$].column<>'''.
此查询:
select distinct [report$].column,[report$].columnIndex
from [report$]
where [report$].column<>''
order by columnIndex
给出了这个错误:
ORDER BY clause (columnIndex) conflicts with DISTINCT.
如何编写此查询以获取唯一值?
答案 0 :(得分:2)
WHERE
在GROUP BY
<>
相当于!=
,因此您应该传递值以将[report$].column
与。{/ p>
No value given for one or more required parameters.
的原因可能是拼写错误的字段名称。
例如:
WHERE [report$].column <> ''
GROUP BY [report$].column,[report$].columnIndex
ORDER BY [report$].columnIndex