I am trying to create an index on CASE expression, as follows
CREATE TABLE test(i INT, j INT);
CREATE UNIQUE INDEX test_index ON test(CASE WHEN i=1 THEN j END);
Getting this error:
ERROR: syntax error at or near "CASE"
LINE 1: CREATE UNIQUE INDEX test_index ON test(CASE WHEN i=1 THEN j ...
^
********** Error **********
ERROR: syntax error at or near "CASE"
SQL state: 42601
Character: 40
What am I doing wrong?
Postgres 9.5.2