sql - Please assist with case when statement -


i assistance creating case when statement in query.

i have following query trying modify

case    when hotelexpenses between convert(varchar(10), getdate(),121)  , convert(varchar(10),dateadd(mm,6,getdate()),121)                  , engagementexpenses between convert(varchar(10), getdate(),121) , convert(varchar(10),dateadd(mm,6,getdate()),121)                 , travelexpenses between convert(varchar(10), getdate(),121) , convert(varchar(10),dateadd(mm,6,getdate()),121)         'yes'         else 'no'  end combinedflag 

i add additional condition lets hotelexpenses, when hoteexpenses > $100.00 , engagementexpenses >100.00 , travelexpenses > 100.00 , if of above conditions have met in addition case statement flag should 'yes' or else 'no' end abc

now in scenarios conditions meet hotelexpenses not other 2 flag should yes if hotelexpenses>100.00 , remaining 2 <100.00 . (makes sense?) if 3 matches date criteria , not meet amount flag should no.

so main questions how can use case when statement 'and' & 'or' in statement . possible?

thank in advance.

are looking :-

case    when hotelexpenses between convert(varchar(10), getdate(),121)  , convert(varchar(10),dateadd(mm,6,getdate()),121)                  , engagementexpenses between convert(varchar(10), getdate(),121) , convert(varchar(10),dateadd(mm,6,getdate()),121)                 , travelexpenses between convert(varchar(10), getdate(),121) , convert(varchar(10),dateadd(mm,6,getdate()),121)                 , (hotelexpenses > 100 or engagementexpenses > 100 or travelexpenses > 100)          'yes'         else 'no'  end combinedflag 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -