有一个表结构如下:
 BH    DJ
A01    1.2
A02    1.0
A03    5.3
A04    4.5有一个公式如下:GS=A02*A03请问我要写一查询语句查询出由公式组成的所有编号;
以上结果为:
BH   DJ
A02  1.0
A03  5.3
注意:表的扩展名为.db

解决方案 »

  1.   

    给点思路
    1、分析出公式中的所有变量;如:GS:= A02*(A03+A04)/0.6中应该分析出A02,A03,A04为变
       量,其它的为符号或常数。
    2、按取出的变量读取表。where bh in ('A02','A03','A04').
      

  2.   

    该SQL语句在SQL Server运行正确。
    select BH from table a, table b where a. DJ in(GS/b.DJ)
      

  3.   

    所以用Delphi可以写成这样:
    例如使用ADOQueryvar
      vGS: Double;
    begin
      with ADOQuery do
      begin
        Active := false;
        SQL.Clear;
        SQL.Add('select BH from table a, table b where a. DJ in(:GS/b.DJ)');
        Parameters[0].Values := vGS;
        Active := True;
      end;
    end;
      

  4.   

    所以用Delphi可以写成这样:
    例如使用ADOQueryvar
      vGS: Double;
    begin
      with ADOQuery do
      begin
        Active := false;
        SQL.Clear;
        SQL.Add('select BH from table a, table b where a. DJ in(:GS/b.DJ)');
        Parameters[0].Value := vGS;
        Active := True;
      end;
    end;你可以试试