开发者

Access db jet sql if else in query

i am using microsoft access jet sql.

i have table col1 and col2

i want to have if else check in sele开发者_如何学Pythonct query like as follows

select col1, if(col2 <10) then 'less then 10' else if(col2 < =20) then 'less then 20')

any quick help


IIF([col2]<10, "Less then 10", IIF([col2]<=20, "Less then20", "something else"))


Use the SWITCH() function, which Access's (ACE's, Jet's, whatever's) analogy of Standard SQL's CASE expression e.g.

SELECT col1, 
       SWITCH ( 
               col2 < 10, 'Less than 10', 
               col2 <= 20, 'Less than or equal to 20', 
               TRUE, 'something else'
              ) AS col2_narrative, ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜