Here is an extract of my table:
gid | datepose | pvc
---------+----------------+------------
1 | 1961 | 01
2 | 1949 |
3 | 1990 | 02
1 | 1981 |
1 | | 03
1 | |
I want to fill the PVC column using a SELECT CASE
as bellow:
SELECT
gid,
CASE
WHEN (pvc IS NULL OR pvc = '') AND datpose < 1980) THEN '01'
WHEN (pvc IS NULL OR pvc = '') AND datpose >= 1980) THEN '02'
WHEN (pvc IS NULL OR pvc = '') AND (datpose IS NULL OR datpose = 0) THEN '03'
END AS pvc
FROM my_table ;
The result is the same content as source table, nothing has happened and I get no error message in pg_log files. It might be a syntax error, or a problem with using multiple conditions within WHEN clauses?
Thanks for help and advice!