时间:2021-07-01 10:21:17 帮助过:24人阅读
2.case when
case 列名
when 条件 then 结果
else 其它结果
end 别名
例:
SELECT CASE detail.`status` WHEN ‘0‘ THEN ‘未开仓‘ WHEN ‘1‘ THEN ‘已开仓‘ WHEN ‘2‘ THEN ‘已平仓‘ ELSE ‘取消订单‘ END status, CASE o.type WHEN ‘0‘ THEN ‘单期‘ WHEN ‘1‘ THEN ‘多期‘ ELSE ‘策略‘ END typeName FROM t_order_detail detail LEFT JOIN t_order o ON o.id = detail.orderId
sql语句if,case when
标签:span expr pen account sel bsp blog mount nbsp