在 select 语句中,有一个字段aaa是integer ,值是0或1,我要显示成 yes/noselect case aaa when 1 then 'yes' else 'no' end from table 为什么报错?

解决方案 »

  1.   

    是这样写的嘛?
    var
      strsql: string;
    begin
      strsql := ' select case aaa when 1 then ''yes'' else ''no'' end from table ';
      

  2.   

    select case aaa when 1 then 'yes' else 'no' end as aaa from table 
    少了as aaa
      

  3.   

    没有问题啊,是否你的 table 有问题,如果名称是就是table用
    select case aaa when 1 then 'yes' else 'no' end from [table]
      

  4.   

    用dbgrideh这个问题很很好解决。
    另外,你可以在字段aaa的ongetText事件中处理
     if sender.asinteger=0 then text='NO'
       else if sender.asinteger=1 then text='yes'
    DisplayText:=true;
      

  5.   

    select case when aaa=1 then 'yes' else 'no' end as aaa from table
    //
    select case when aaa=1 then '1'
                when aaa=2 then '2'
                else '0' end as aaa from table
      

  6.   

    同意 firetoucher(风焱) :
      这语句没有错,Table 为关键字,加个[]试试!
      

  7.   

    哎,查出来了。我的是个union 语句,在另一个select中没改 ....
    thanks all ~~~~~~~~~~~~~