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


先记录到此,哈哈
posted @ 2015-03-12 11:07  ching126  阅读(1205)  评论(0编辑  收藏  举报
一个小小的平凡的事情坚持10年,回头看看,你会收获惊喜;坚持20年,回头看看,你的命运已经发生质的蜕变;坚持30年甚至更多年,回头看看,你的人生已经发生惊天动地的变化。