简体   繁体   中英

Using a Case statement IN where clause

Problem: When category= books & FMCG then shipping_cost less then selling_price else no check.. Please suggest..:)

Actual Condition: WHERE a.shipping_cost < a.selling_price

Expected Condition: WHERE CASE WHEN a.category IN('Books','FMCG') then a.shipping_cost < a.selling_price END

You could put it like that i think :

WHERE (a.category IN('Books','FMCG') AND a.shipping_cost < a.selling_price) OR 
  (a.category NOT IN('Books','FMCG'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM