这里主要是实现一个表中多个字段,多个字段之间作比较然后取得最大值或者最小值用来处理
case when then else end 例子
<span style="font-family:Microsoft YaHei;font-size:14px;">selece f1,f2,(case when f1>f2 then f1 else f2 end) as a from table</span>
但是发现在access中不好使
接下来使用access支持的switch代替如下
<span style="font-family:Microsoft YaHei;font-size:14px;">select * from ( select topvalue,bottomvalue,leftvalue,rightvalue, switch ( a > b,a, a <= b,b ) as result from ( select topvalue,bottomvalue,leftvalue,rightvalue, switch ( topvalue > bottomvalue,topvalue, topvalue <= bottomvalue,bottomvalue ) as a, switch ( leftvalue > rightvalue,leftvalue, leftvalue <= rightvalue,rightvalue ) as b from imagehandle ) ) order by result desc 查询结果截图如下: <img src="http://img.blog.csdn.net/20150312110307552?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hlbmhvbmd3dTY2Ng==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /></span>
在此记录一下,哈哈
时间: 2024-10-06 02:39:45