Skip to content
Advertisement

How to sum the values of two columns and have it in a new one? [closed]

I’m trying to sum the values of two columns into a new one, its for analysis purpose (not creating a new column in the database) I tried using case statement but I have no idea what is happening :
(Basically what I’m trying to say is: if the sum of the 2 columns is equal or grater than one, then count it as 1, if its 0 or null then skip and return zero) please see the attached pictures

enter image description here

enter image description here

Advertisement

Answer

If you are trying to get the the sum of the two columns, you just need ton handle the null values properly.

SELECT COALESCE(speciality_count, 0) + COALESCE(Italian_count, 0)
FROM table_name 
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement