您好,登录后才能下订单哦!
【
问题详细
描述】
 
 
在
SequoiaDB
中,在
group by 
时,
decimal
(高精度数)
类
型的字段可以做
sum
函数
吗
?
 
【解决
办
法】
 
 1.decimal
类型是支持在
group by 
时做聚集函数的,
例如:
 
 
集合
cl
中
现
有如下数据:
 
 {"a":{"$decimal":"111.111"},"name":"zhangsan"} 
 {"a":{"$decimal":"222.222"},"name":"zhangsan"} 
 {"a":{"$decimal":"123.456"},"name":"lisi"} 
 2.
在使用
group by 
时对
decimal
类型的
 'a' 
字段做聚集函数
 
 db.exec("select sum(a) as 
总和
 from cs.cl group by name") 
 3.
结果如下:
 
 {"
总和
":{"$decimal":"123.456"}} 
 {"
总和
":{"$decimal":"333.333"}} 
 
 
【
详
情参考】
 
 
高精度数:
http://doc.sequoiadb.com/cn/SequoiaDB-cat_id-1519612297-edition_id-300
 
 
聚集函数:
http://doc.sequoiadb.com/cn/index-cat_id-1432190972-edition_id-300
【解决
办法】
 
 decimal
类型是支持在
group by 
时做聚集函数的,例如:
 
 1.
集合
cl
中
现
有如下数据:
 
 {"a":{"$decimal":"111.111"},"name":"zhangsan"} 
 {"a":{"$decimal":"222.222"},"name":"zhangsan"} 
 {"a":{"$decimal":"123.456"},"name":"lisi"} 
 2.
在使用
group by 
时对
decimal
类型的
 'a' 
字段做聚集函数
 
 db.exec("select sum(a) as 
总和
 from cs.cl group by name") 
 3.
结果如下:
 
 {"
总和
":{"$decimal":"123.456"}} 
 {"
总和
":{"$decimal":"333.333"}} 
 
 
【
详
情参考】
 
 
高精度数:
http://doc.sequoiadb.com/cn/SequoiaDB-cat_id-1519612297-edition_id-300
 
 
聚集函数:
http://doc.sequoiadb.com/cn/index-cat_id-1432190972-edition_id-300
 
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。