如题:
数据库的结构是这样的,只有一个字段“数值”数值
2456797
2349513
6786943
2345697
...
过滤后,得出的结果为2456797。 都是含有三个偶数的记录,既不是二个,也不是四个。
                    2345697  

解决方案 »

  1.   

    select 
    * from where 
    (case when substring(数值,1,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,2,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,3,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,4,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,5,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,6,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,7,1) in('0','2','4','6','8') then 1 else 0 end)=3
      

  2.   

    select 
    * from 表名 where 
    (case when substring(数值,1,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,2,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,3,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,4,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,5,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,6,1) in('0','2','4','6','8') then 1 else 0 end)+
    (case when substring(数值,7,1) in('0','2','4','6','8') then 1 else 0 end)=3
      

  3.   

    出错呀,我从来没这么写过呀
    这是标准的SQL语句吗
      

  4.   

    你用的是什么数据库?我一般写出来的代码基本上是基于MS SQL 2000,因为我接触MSSQL相对比较多。
      

  5.   

    var
      i:integer;
      count:integer;
      a:string;
    with adoquery1 do
    begin
      sql.clear;
      sql.add('select * from table');
      open;
      while not eof do
      begin
        a:=Fieldbyname('数值')
        for i:=0 to length(a)-1 do
        begin
          if strtoint(a[i])div 2 = 0 then//是偶数
             count=count+1;
        end;
        if count=3//含有3个 then
          listview.items.add('a');//提取出来;
        next;
      end;
    end;
      

  6.   

    以上假设数据库中类型为nvchar(50)
      

  7.   

    上面代码改一下倒数第4,5行
    自己加上listview1这个控件,其他的也可以
    =================
    if count=3 then//含有3个 
          listview1.items.add('a');//提取出来;
      

  8.   

    用的是paradox的数据库??? 那就晕了只能手动处理吧(不知道BDE的组件是否支持)。
      

  9.   

    to kshape
    你用的是标准的SQL 语句吗