简体   繁体   English

使用 Case 语句 IN where 子句

[英]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实际情况:WHERE a.shipping_cost < a. sell_price

Expected Condition: WHERE CASE WHEN a.category IN('Books','FMCG') then a.shipping_cost < a.selling_price END预期条件:WHERE CASE WHEN a.category IN('Books','FMCG') then a.shipping_cost < a. sell_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'))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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