This might be obscure but I want to set a max value on an integer in one of my queries. Basically if the value rawsentiment is greater than 500, I just want to have it be 500 but if its less, than I want it to use that value. Would this be possible? It looks like this:
SELECT avg( rawsentiment * magic_coefficient ) FROM sentiment
But I need to do something like this (warning it looks very non-SQL like)
SELECT avg( ( 500 if (rawsentiment>500) else (rawsentiment) ) * magic_coefficient) FROM sentiment
You will want to check out MySQL Least
something like (untested):