【发布时间】:2015-12-21 07:22:42
【问题描述】:
以下是“pc”表,其中包含有关 pc 的详细信息。
user=> SELECT * FROM pc;
code | model | speed | ram | hd | cd | price
------+----------+-------+------+------+-----+---------
101 | Imac | 2000 | 4096 | 500 | 16x | ₹550.00
102 | G450 | 1500 | 2048 | 500 | 8x | ₹450.00
(2 rows)
user=>
现在我想取价格的平均值。于是尝试了以下方法。但它会产生错误。
user=> SELECT AVG(price) FROM pc;
ERROR: function avg(money) does not exist
LINE 1: SELECT AVG(price) FROM pc;
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
user=>
那么,获取货币数据类型中价格列的平均值的方法是什么。
【问题讨论】:
-
这是我发现 money 数据类型完全没用的原因之一。
标签: sql regex postgresql average postgresql-8.4