Home > Enterprise >  How to sum the values of two columns and have it in a new one?
How to sum the values of two columns and have it in a new one?

Time:12-19

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

CodePudding user response:

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 
  • Related