case when 的实战应用
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了case when 的实战应用相关的知识,希望对你有一定的参考价值。
SELECT lg.product_id, lg.goods_id, lg.goods_no, lg.product_price, lg.product_stock, lg.limit_amount, lg.is_delivery_free, lg.limit_order, lg.state, gs.MARKET_PRICE, lg.standby1 AS kan_product_stock, sg.goods_name, <![CDATA[ (CASE WHEN lg.LIMIT_GOODS_IMG IS NOT NULL THEN lg.LIMIT_GOODS_IMG ELSE sg.goods_list_img END ) AS goods_list_img, ]]> sg.goods_price, lg.cu_title FROM T_LIMIT_GOODS lg, shop_common_goods sg, ( SELECT gg.market_price, gg.goods_id FROM product pp, goods gg WHERE gg.PRODUCT_ID = pp.product_id AND pp.is_onsale = ‘Y‘ AND pp.is_delete = ‘N‘ AND gg.is_delete = ‘N‘ ) gs WHERE lg.goods_id = sg.goods_id(+) AND lg.goods_id = gs.goods_id AND lg.is_delete = ‘N‘ AND sg.is_delete = ‘N‘ AND lg.state = ‘enable‘ AND <!
[CDATA[ to_date(lg.limit_begin_time, ‘YYYY/MM/DD hh24:mi:ss‘)<=to_date(#{limitEndTime}, ‘YYYY/MM/DD hh24:mi:ss‘)]]> AND sg.goods_type = #{goodsType} AND lg.field_id = #{fieldId} ORDER BY lg.LIMIT_ORDER
以上是关于case when 的实战应用的主要内容,如果未能解决你的问题,请参考以下文章
R语言dplyr包使用case_when函数和mutate函数生成新的数据列实战:基于单列生成新的数据列基于多列生成新的数据列