select count(distinct colname) from table1 提示标识符无效

jinyongfans 2011-08-08 02:43:13
我用VB连接ORACLE
程序中显示SQL语句是 select count(distinct box) from table1
然后运行到这里就出错, 说ORA- distinctbox标识符无效,它把distinctbox连在了一起,当中无空格。
但是同样的语句拷到 PL/SQL Developer中却运行正常
我改成select count(distinct box) a from table1 也不行,同样的错误,它就是把distinct box 当成了distinctbox

请问什么原因呢?

...全文
412 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinglingqaz 2011-08-09
  • 打赏
  • 举报
回复
应该是别的情况引起的问题,看看是不是驱动或者别的原因
with table1 as (
select 'box1' box from dual
union all
select 'box2' box from dual
union all
select 'box3' box from dual
)
select count(distinct box) a from table1
yixilan 2011-08-09
  • 打赏
  • 举报
回复
with table1 as,这个语法没用过。学习一下。
灰哥 2011-08-08
  • 打赏
  • 举报
回复
我想不管是什么语言,只要连上了数据库的接口就应该会把语句交给数据库,按照数据库的规范执行。
应该不会说把(distinct box )给放一起了。
可能是其他原因引起的。
insist_study 2011-08-08
  • 打赏
  • 举报
回复
SQL> select count(distinct deptno) from scott.emp;


COUNT(DISTINCTDEPTNO)
---------------------
3

SQL>
小让 2011-08-08
  • 打赏
  • 举报
回复
试试这样吧

with a as (select distinct box from table1 )
select count(*) from a
yangqm22 2011-08-08
  • 打赏
  • 举报
回复
估计是VB的规则问题。没有弄过,你可以改为select count(*) from (select box from table1 group by box)
luoyoumou 2011-08-08
  • 打赏
  • 举报
回复
-- 估计是:人品问题!

scott@TBWORA> select count(distinct deptno) from emp;

COUNT(DISTINCTDEPTNO)
---------------------
3

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧