| 发表于:2007-07-13 16:41:184楼 得分:20 |
两种方法:不知道你用哪一种? strsql= "select sum(rowname) total from tablename "; --select sum(列名) total from 表名 resultset rs = stmt.EXECutequery(strsql); int total=0; while(rs.next()){ total=rs.getint( "total "); system.out.println(total); } ------------------------------------- 第二种: strsql= "select cnt(列名) total from 表名 "; resultset rs = stmt.EXECutequery(strsql); int total=0; int cnt=0; while(rs.next()){ cnt=rs.getint( "cnt "); total=total+cnt; } system.out.println(total); | | |
|