wq8660389 2016-12-09 14:03 采纳率: 35.7%
浏览 1160
已结题

sql的sum函数输出(请详细回答,解决了立马采纳)

请问怎么才能把gr_totalfee的和在控制台输出出来

代码1:

select sum(gr_totalfee) as gr_totalfeevalue
from core_bill

代码2:
public interface BillMapper {
int deleteByPrimaryKey(String id);

int insert(Bill record);

int insertSelective(Bill record);

Bill selectByPrimaryKey(String id);

Bill selectByPrimaryKey1();

代码3:
@Autowired
BillMapper billMapper;

@RequestMapping("/toBill")
public String toBill() {
    //Bill admin =   billMapper.selectByPrimaryKey1();
    Bill a = billMapper.selectByPrimaryKey1();
    //System.out.println("自费:"+admin.getGrTotalfee());
    //System.out.println("a:"+a);
    System.out.println("a的值:"+a);
    return "index";
}


输出的结果:
INFO impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1bqub5u9k1r7py4mnnjruz|7441cf0d, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1bqub5u9k1r7py4mnnjruz|7441cf0d, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://rdsw49x2tpph3bfc8ldvo.mysql.rds.aliyuncs.com/ykf_test_yufabu?useUnicode=true&characterEncoding=utf-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 2, numHelperThreads -> 3, preferredTestQuery -> SELECT 1 FROM dual, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]

com.dabay.service.web.manager.persistence.dao.BillMapper.selectByPrimaryKey1:select sum(gr_totalfee) as gr_totalfeevalue from core_bill:1458ms
a的值:null
09-Dec-2016 21:44:51.292 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory E:\tomcat\webapps\manager
09-Dec-2016 21:44:51.336 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory E:\tomcat\webapps\manager has finished in 43 ms
com.dabay.service.web.manager.persistence.dao.BillMapper.selectByPrimaryKey1:select sum(gr_totalfee) as gr_totalfeevalue from core_bill:97ms
a的值:null
com.dabay.service.web.manager.persistence.dao.BillMapper.selectByPrimaryKey1:select sum(gr_totalfee) as gr_totalfeevalue from core_bill:124ms
a的值:null

  • 写回答

2条回答 默认 最新

  • 阮二 2016-12-09 14:35
    关注

    如果你的bill 对象 有gr_totalfeevalue属性 可以syso(a.gr_totalfeevalue)

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线