数据库里的内容如下
     a             
------------
    1.0            
    1.5            
    2.0            
    2.5            
    3.0            
.....
.....
.....
  999.5
   1000 
如何做到我键入一个值,就找到与此值最接近的一个值?比如我键入 1.2 ,那么就找到1.0, 我键入 99.3,就找到与它最接近的值99.5。
谢谢!

解决方案 »

  1.   

    你把query的sql语句最后写成 
    order by a desc
    每次插入后重新open
    判断当前记录的想林两条即可
      

  2.   

    select min(abs(a-1.2)) from b
    找出相应的只
    分别locate+1.2,和-1.2的数据
      

  3.   

    Select Name, Age From table1 
    Where Abs(Age - 32) = (Select Min(Abs(Age - 32)) From table1)
      

  4.   

    SELECT MAX(a) FROM TABLE WHERE a =(select a from table where a <= input_num);
    input_num是你輸入的值;
      

  5.   

    或者:min_num:=select min(a-input_num) from table;
    select a from talbe where a=
            (
            select a 
            from (select a,(a-input_num) aa from table group by a) B
            where B.aa=min_num
            )
      

  6.   

    select a from talbe where a=
            (
            select a 
            from (select a,(a-input_num) aa from table group by a) B
            where B.aa=(select min(a-input_num) from table )
            )