hibernate使用聚合函数SUM()

来源:百度知道 编辑:UC知道 时间:2024/05/31 13:02:22
hibernate使用聚合函数SUM()为什么得到的是小数,不是整数
String hql = "select SUM(artAnsowerNum) from Artic where enterTime between ? and ? and project.prjId=?";
或String sql = "select SUM(art_ansower_num) from artic where enter_time between ? and ? and prj_id=?";
都是小数,如何能得到整数呢?
“ceiling,向上取整
floor是向下取整
round(a,0) 四舍五入 ”
他们都是hibernate里的吗?还是数据库的?

select ceiling(SUM(artAnsowerNum)) from Artic where enterTime between ? and ? and project.prjId=?

用ceiling,向上取整
floor是向下取整
round(a,0) 四舍五入
---------------------------------------------
数据库的

artAnsowerNum 本身就不是小数,你可以这样一试,看结果
sum(convert(int,artAnsowerNum))