switch statement - Name an output column created with case in PostgreSQL -
is possible name output column created case
("switch") in postgresql select
statement? appears documentation not possible. example usage of is:
select case (column) when 1 'one' end 'thecolumn' table ;
it works me (pg-9.1)
create table 1 ( 1 integer ); insert one(one) values ( 0), (1), (null); select case 1 when 1 'one' when 0 'zero' else 'other' end the_one one;
so, single quotes (that used quote aliased column name) should have been double quotes (or absent).
the result:
create table insert 0 3 update 3 the_one --------- 1 0 other (3 rows)
Comments
Post a Comment