在对当前查询使用round时需要帮助吗

lp0sw83n  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(359)
SELECT
    (TS_LEXIZE('english_stem',
               UNNEST(STRING_TO_ARRAY(
                   REGEXP_REPLACE(feedback, '[^a-zA-Z]+', ' ', 'g'),
                   ' ')
               )))[1] AS token,
    AVG(rating) AS avg_rating
FROM customer_survey 
GROUP BY 1
HAVING COUNT(1) >= 3
ORDER BY 2 DESC
;

我有下面的问题,如果你想限制评分到小数点后2位,你会在哪里加上round()?

8gsdolmq

8gsdolmq1#

SELECT
    (TS_LEXIZE('english_stem',
               UNNEST(STRING_TO_ARRAY(
                   REGEXP_REPLACE(feedback, '[^a-zA-Z]+', ' ', 'g'),
                   ' ')
               )))[1] AS token,
    ROUND(AVG(rating)) AS avg_rating
FROM customer_survey 
GROUP BY 1
HAVING COUNT(1) >= 3
ORDER BY 2 DESC
;

在平均值之前加上一轮我就得到了。

相关问题