求某字段的最大值的代码如何写?
TKS!

解决方案 »

  1.   

    select max(字段) from 表 where 条件 OK???
      

  2.   

    如果可以用数组表示的话就这样:begin
       for i:=low(array) to high(array)-1//你不这么写也行,目的就是索引
       begin 
          temp:=max(array[i],array[i+1]);
       end;
    end;
      

  3.   

    谢谢各位。其实我要的是这样的:在sql表中有一字段BillNo,要取字段值为'20040704'开头的最大值
      

  4.   

    Selet Max(Field_Name) from Table_Name
      

  5.   

    Selet Max(BillNo) from Table_Name where BillNo like '20040704'
      

  6.   

    linjie208(御风而行),你的Select写错了,应该是:
    Select Max(BillNo) from Table_Name where BillNo like '20040704'
      

  7.   

    Select Max(right(length(BillNo)-8,billno)) from Table_Name where convert(char(8),left(BillNo,8),112)='20040704'
    like 大数据量 会变慢