我用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请问什么原因呢?

解决方案 »

  1.   

    -- 估计是:人品问题!scott@TBWORA> select count(distinct deptno) from emp;COUNT(DISTINCTDEPTNO)
    ---------------------
                        3
      

  2.   

    估计是VB的规则问题。没有弄过,你可以改为select count(*) from (select box from table1   group by box)
      

  3.   

    试试这样吧with a as (select distinct box from table1 )
    select count(*) from a
      

  4.   

    SQL> select count(distinct deptno) from scott.emp; 
    COUNT(DISTINCTDEPTNO)
    ---------------------
                        3
     
    SQL> 
      

  5.   

    我想不管是什么语言,只要连上了数据库的接口就应该会把语句交给数据库,按照数据库的规范执行。
    应该不会说把(distinct box )给放一起了。
    可能是其他原因引起的。
      

  6.   

    应该是别的情况引起的问题,看看是不是驱动或者别的原因
    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 
      

  7.   

    with table1 as,这个语法没用过。学习一下。