创建物化视图并分割列

时间:2017-08-31 15:40:18

标签: postgresql

我试图通过物化视图查询将我所拥有的一列变成小数,并且我很难这样做。

表格中的My Current列如下所示

Search Exact match IS
5.32

我想要以下

Search Exact match IS
.0532

我正试图通过这条线来实现这一目标,并在#34; CREATE MATERIALIZED VIEW"查询

CASE "Search Exact match IS"
            When "Search Exact match IS" > 0 then ("Search Exact match IS" / 
100)
             Else 0
         End AS "Search Exact match IS",

但我遇到了此错误消息;

ERROR:  operator does not exist: double precision = boolean
LINE 32:             When "Search Exact match IS" > 0 then ("Search E...
                 ^
HINT:  No operator matches the given name and argument type(s). You might 
need to add explicit type casts.
********** Error **********

ERROR: operator does not exist: double precision = boolean
SQL state: 42883
Hint: No operator matches the given name and argument type(s). You might 
need to add explicit type casts.
Character: 558

我是否应该尝试通过案例找到解决方案?

由于

1 个答案:

答案 0 :(得分:1)

改变这个:

CASE "Search Exact match IS"
        When "Search Exact match IS" > 0 then ("Search Exact match IS" / 100)
         Else 0
     End AS "Search Exact match IS",

对此:

CASE
    When "Search Exact match IS" > 0 then ("Search Exact match IS" / 100)
    Else 0
End AS "Search Exact match IS",

https://www.postgresql.org/docs/current/static/functions-conditional.html#FUNCTIONS-CASE