Consider the following, in PostgreSQL:
drop table test ; create table test (result1 text, red smallint, green smallint, blue smallint, results2 text) ; insert into test values ('red',1,2,3) ;
I would like
results2 to contain the value
blue, indicating that the maximum value for the integer columns occurs in column
blue. This can be achieved by running an
UPDATE or a function at a later time.
How do I insert the column name as a value? As an example, the row above would be updated such that it contains:
'red', 1, 2, 3, 'blue'
There will not be
NULL values for the integer columns and one of the integers will always be the largest.
(See also here.)