In my PostgreSQL database I have the following schema:
CREATE TABLE slide_results (
id integer NOT NULL,
tags character varying[] DEFAULT '{}'::character varying[]
);
INSERT INTO slide_results (id, tags)
VALUES (1, '{Food, Housing}');
INSERT INTO slide_results (id, tags)
VALUES (2, '{Security, Transport}');
Now I want to have sql query that will return one additional column, this column name is domain_name
. Value of this column depends on what tags
column have. If tags
column have Food
value then domain_name
should be I need food help
, if tags include Transport
then domain_name
will have Transport help needed
. So result of the query should be
id | domain_name
1 | I need food help
2 | Transport help needed
How can I do something like this in PostgreSQL?
Here is sql fiddle with db schema: