my mysql table is like this:
id value
1 10
2 20
3 30
4 40
5 50
there are two args:start and end, what i want is like this:
when start=end, the result is 0
when start>end, the result is 'sum(value) where id<=start and id>end'
when start<end, the result is 'sum(value) where id>start and id<=end'
how to write the sql to get the result? maybe 'case when then' is a good choice but i do not know how to write.