Skip to content
Advertisement

SQL or function

In SQl its common to take the SUM of all values from a column

SELECT SUM(column_name)
FROM table_name
WHERE condition;

Can the same thing be done but instead of summing each value in an attribute, each value is “OR’d” together? This would only work if the attribute was boolean of course

Advertisement

Answer

MAX(booleancolumn) will return OR’d together. (Since TRUE > FALSE.)

Note that this will not work if null values are involved, because FALSE OR NULL evaluates to NULL.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement