'Update a table of sums to only contain one row

I have a table names bacteria, which contains sums. There is only one decimal point number in each column, the rest being nulls. Is there a way for me to update the table into removing the NULLS and merging all the decimals into one row? I need to keep the header so MAX doesn't work.

phe leu ser ile
0.04248683 NULL NULL NULL
NULL 0.09419620 NULL NULL
NULL NULL 0.06114061 NULL
NULL NULL NULL 0.05847198

I tried update to set all the NULLs to 0 but still can't figure out a way to add the rows.

update bacteria set phe= 0 where phe is null
update bacteria set leu= 0 where  leu is null
update bacteria set ser= 0 where  ser is null
update bacteria set ile= 0 where  ile is null

I've also have tried different variations of

update bacteria set sum(phe).

Desired result is

phe leu ser ile
0.04248683 0.09419620 0.06114061 0.05847198

Any help is appreciated as I'm still learning.



Solution 1:[1]

You need to create a new table or update you table first add a new column, next an example of how you can do it if you want create a new table:

SELECT *
INTO newtable
FROM (select MAX(phe) as phe, MAX(leu) as leu, MAX(ser) as ser, MAX(ile) as ile  from bacteria) 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dale K