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)

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型