with datamodule_ly.ADODataSet_consume  doClose;
CommandType := cmdtext;
CommandText := ' select sum(consume) as sumconsume from      group_consume,con_place where con_place.con_place_code =(select con_place_code from con_place where place_belong = :Vhotel_id ) and con_Time > :vdatetime  group by group_consume.consume ';
 Parameters.ParamByName('Vhotel_id').Value :=hotelid;
 Parameters.ParamByName('vdatetime').Value := strtodatetime(date);
Open;报错信息为:“ora-00979:不是group by 表达式”
我用数据代替变量又没有问题,有哪位兄弟遇到过这种情况,怎么解决呢,请帮忙呀。

解决方案 »

  1.   

    CommandText 里面的內容引起的錯誤。自己再找找吧。
      

  2.   

    看一看这一句:
    CommandText := ' select sum(consume) as sumconsume from      group_consume,con_place where con_place.con_place_code =(select con_place_code from con_place where place_belong = :Vhotel_id ) and (con_Time > :vdatetime)  group by group_consume.consume '
      

  3.   

    类似的SQL语句也报错:
     sql.add(' select sum(income)  from agency_income where agency_code = :agencycode and income_time >= :date ');
    ORACLE9 报错信息是:ora-00937:非单组分组函数
    各位帮忙呀
      

  4.   

    但是放到PL/SQL中用数值代替变量就没问题了,真是不明白,请高手指教!!!!
      

  5.   

    使用断点,把sql取出来去执行。
      

  6.   

    应该是group by sumconsume吧
    因为你的结果里没有字段consume,所以group by就要报错呀
      

  7.   

    to chenquan(嘉威王子) 和 idilent(说错了别怪我)加Parameters.clear没用,错误仍然是非单组分组函数
    使用断点呀,错误如上。
      

  8.   

    你用的是ADOCOMMAND吧?MS提供的ORACLE驱动有问题,你用BDE就不会有问题,这个问题我遇到很多次,我也不知道是什么原因,反正不用参数,用动态SQL就没有问题,请高手来解释一下
      

  9.   

    to  delphi_xizhousheng(西周生)
    我用的是ADODATASET,不知你所说的动态SQL是什么意思,可以举一个例子吗?请帮忙
      

  10.   

    //试试下面:
    with datamodule_ly.ADODataSet_consume  do
    Close;
    CommandType := cmdtext;
    CommandText := ' select sum(consume) as sumconsume from      group_consume,con_place where con_place.con_place_code =(select con_place_code from con_place where place_belong = '+hotelid+') and con_Time > '''date''' group by group_consume.consume ';
    Open;
      

  11.   

    CommandText := ' select sum(consume) as "sumconsume" from      group_consume,con_place where (con_place.con_place_code =(select con_place_code from con_place where place_belong = :Vhotel_id )) and (con_Time > :vdatetime)  group by group_consume.consume ';
      

  12.   

    还是不行呀,报错信息还是:ora-00937:非单组分组函数