求总数的函数怎么写

chitu11 2011-02-14 11:06:06
我想从数据库当中求总数,但是不知道怎么写了

public int getMin(String str){
int count =0;
try {
Statement stmt = SumCard.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(str) ;




} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return count;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new SumCard().getMin("select min(cjsj) from t_cards t ");
}



...全文
194 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chitu11 2011-02-14
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lostmarine 的回复:]

Statement stmt = SumCard.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(str) ;
double min = 0 ;
double sum = 0 ;
if(rs.next()){
min = Double.parseDouble……
[/Quote]
谢啦,我想起来了
lostmarine 2011-02-14
  • 打赏
  • 举报
回复
Statement stmt = SumCard.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(str) ;
double min = 0 ;
double sum = 0 ;
if(rs.next()){
min = Double.parseDouble(rs.getString("min1")) ;
sum = Double.parseDouble(rs.getString("sum1")) ;
}
shanxmxj 2011-02-14
  • 打赏
  • 举报
回复
你要求什么总数 把需求说清楚
chitu11 2011-02-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lostmarine 的回复:]

new SumCard().getMin("select min(cjsj) as min1 , sum(cjsj) as sum1 from t_cards t ");
[/Quote]

我想知道上面的那个函数怎么写,就是中间的空余部分怎么取
lostmarine 2011-02-14
  • 打赏
  • 举报
回复
new SumCard().getMin("select min(cjsj) as min1 , sum(cjsj) as sum1 from t_cards t ");

62,634

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧