Help with MAX sensor value

Are you using the SQL sensor integration or are you doing this outside of HA?

When you say “doesn’t work”, what happens? What error messages do you see?

If you are using the SQL sensor, please post your code here (see rule 11). Could be something as simple as a formatting error.