私のmysqlテーブルは次のようなものです:
id value
1 10
2 20
3 30
4 40
5 50
start と end の 2 つの引数があります。私が欲しいのは次のようなものです。
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'
結果を取得するためのSQLの書き方は?おそらく「case when then」は良い選択ですが、書き方がわかりません。