var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: How to sum multiple fields together
I am still learning by the "Trial by Fire" method. Thanks for all previous help!
Table name: Class_1
Field names: Rating_5; Rating_4; Rating_3; Rating_2; Rating_1; Rating; 0; Not_Rated
Is this the correct SQL way to sum up one field: Select sum(Rating_5) from Class_1
How would I sum each field and then add the sums together?
Also what is Firebird SQL?
Yes, that is the correct way to sum one column.
If the columns don't allow NULL values, you can just add the sums together. If they do allow NULL values, you have to be a bit more defensive, something like:
SELECT Sum(rating1) AS rating1
, Sum(rating2) AS rating2
, Sum(rating3) AS rating3
, Sum(rating4) AS rating4
, Sum(rating5) AS rating5
, Coalesce(Sum(rating1), 0)
+ Coalesce(Sum(rating2), 0)
+ Coalesce(Sum(rating3), 0)
+ Coalesce(Sum(rating4), 0)
+ Coalesce(Sum(rating5), 0) AS all_ratings
Thank you for your response
Thank you for your response. I will give it a go.