背景:表中存在多個字段,對比查出最大、最小值
1、最大值greatest
select greatest(字段1,字段2,字段N) maxs from 表
where a.條件= '條件值'
執行結果:
2、最小值least
select least(字段1,字段2,字段N) maxs from 表
where a.條件= '條件值'
執行結果:
背景:表中存在多個字段,對比查出最大、最小值
select greatest(字段1,字段2,字段N) maxs from 表
where a.條件= '條件值'
執行結果:
select least(字段1,字段2,字段N) maxs from 表
where a.條件= '條件值'
執行結果: