Access 中case when then else end不支持使用switch代替

Access 中case when then else end不支持使用switch代替

这里主要是实现一个表中多个字段,多个字段之间作比较然后取得最大值或者最小值用来处理

case when then else end 例子

selece f1,f2,(case when f1>f2 then f1 else f2 end) as a from table

 

但是发现在access中不好使

接下来使用access支持的switch代替如下

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
查询结果截图如下


先记录到此,哈哈
原文地址:https://www.cnblogs.com/ching2009/p/4331865.html