我正在Cloudera VM的Hue编辑器中编写配置单元查询。但不知何故,我无法获得两个小数位的数据。相同的代码如果我在shell上运行,它会给出正确的结果。我使用的是cloudera的最新版本。
select u.column1, r.column2, AVG(round(r.metric,2)) as avgr from table1 r, table2 u where u.userid= r.userid and r.metric is not null group by u.column1, r.column2;

发布于 2019-03-12 02:59:49
round()返回double,AVG()也返回double。
最好在AVG之后申请轮次:
round(AVG(r.metric),2)如果图形用户界面仍然不能正确显示,请显式转换为decimal:
cast(round(AVG(r.metric),2) as decimal(19,2)) https://stackoverflow.com/questions/55106575
复制相似问题