The maximum

Category: Delphi -> VCL/Component Author: JHYLXYLWT Date: 2013-09-02 08:57:05
 
JHYLXYLWT
2013-09-02 08:57:05
q: a table as follows:
id ordered time
1 13:33
2 21:00
..
I want to find the largest id number assigned to the OrderID
how to do it

I know sql.add ('select max (id) from order information');
can find the largest of the id, but how is assigned OrderID
wikiff
2013-09-02 09:02:09
If it is SQLServer, then
Query1.SQL.Add ('Select Isnull (Max (id), 0) as MaxID from order information ');
If yes, then Access
Query1.SQL.Add (' Select IIF (isnull (Max (id)), 0, Max (id) ) as MaxID from order information ');
Query1.Open;
OrderID: = Query1.FieldsByName (' MaxID '). AsInteger;
cxc116
2013-09-02 09:08:40
sql.add ('select isnull (max (id), 0) as maxid from order information');
sql.ExecSQL;
OrderID: = sql.FieldByName ('maxid'). value;
fjh2ll
2013-09-02 09:23:44
Query1.SQL.Add ('Select Max (i) from order information');
Query1. Open;
OrderID: = Query1.Fields [0]. AsInteger;
MT__COW
2013-09-02 09:39:44
wangyime (wangyime) error lies ADOQUERY perform EXECSQL not return a result set.
CloneCenter (copy center) errors are not taken into account, "If there is no record - that is space-time how to deal with."

mnbnbvjhkjjhhf
2013-09-02 09:47:01
Agree upstairs isnull (max (id), 0) as maxid
zsifghjkt
2013-09-02 10:03:54
If the table is not empty
take Max will be no record of the case it