select sum(moneny) newFD from 表

解决方案 »

  1.   

    what is the error message?
    rs.next() = null?
    does your sql string like "select sum(moneny) from table where ..."
    and actually there in none records satisfy the condition?
      

  2.   

    and you should get the value by "rs.getInteger(1)" or "rs.getInteger("sum(moneny)")"
      

  3.   

    在sqlserver中用这两句都可以查到记录,但用java查,就不行了
    rs.next()有可能为空,该怎么解决?
    感谢两位
      

  4.   

    rs.getInteger(1)有可能为空。
    我怎么查出moneny的各字段总和?
      

  5.   

    rs.next()为空是什么意思??返回的应该是boolean值啊if (rs.next()){}else{}
      

  6.   

    我还是再顶吧,初学java,感谢帮忙。
      

  7.   

    报告是rs.next()处出错。
    用select moneny from 不会错。
    用select sum(moneny) from 报错。
    现在 我想得到moneny的总和,而且moneny有可能为空。
    怎么解决,再加分50求解,好方法再加分。
      

  8.   

    不可以select money from然后取出  money字段一个一个加起来吗?
      

  9.   

    想用sum来做,因为有很多用到的地方。
      

  10.   

    String databaseURL = "jdbc:oracle:thin:@192.168.101.15:1521:[yourDatabaseName]";
    String user = "[yourUser]";
    String password = "[yourPassword]";
    String driverName = "oracle.jdbc.driver.OracleDriver";Class.forName(driverName);
    conn = DriverManager.getConnection(databaseURL, user, password);stmt = conn.createStatement() ;
    sql = "select * from RJ_Fortune";
    System.out.println(sql);
    rs = stmt.executeQuery(sql);if(rs.next())
    {
    // do something what you want to do.
    }
      

  11.   

    and I want to see your complete sql string.
    if the string is right, and the method you use is "executeQuery",and the connection is ok,then such mistake should not exist.
      

  12.   

    --->select sum(tradeNum) from MraketProTradeInfo where proId='05' and tradeSort='2'java.lang.NullPointerException
      

  13.   

    我同意yoobj的看法给查询结果取一个别名就行了
      

  14.   

    同意Fortune2k1(Forune2k1) 的观点
      

  15.   

    select sum(moneny)from 表
    改为
    select sum(moneny) as moneny from 表
      

  16.   

    出现这个问题是数据表是moeny这个字表有可能出现为null的时候,会出现这个问题;
    最好在select sum(money) from table的时候;
    使用select  sum(iif(isnull(money),0,money)) form table; 现在没有办法测试,有条件测试一下,再给你准确答案
      

  17.   

    select sum(isnull(money,0) ) as money from table