如果我在 Impala 中有以下代码:
(CASE
WHEN a3.shipped_qty1 > a4.shipped_qty2 AND a1.min1 < a2.min2 THEN "KEEP"
WHEN a3.shipped_qty1 < a4.shipped_qty2 AND a1.min1 < a2.min2 THEN "MOVE"
WHEN a3.shipped_qty1 > a4.shipped_qty2 AND a1.min1 > a2.min2 THEN "MOVE"
WHEN a3.shipped_qty1 < a4.shipped_qty2 AND a1.min1 > a2.min2 THEN "KEEP"
ELSE "NOT SHIPPING"
END) AS move
我希望文本输出如下内容:
(CASE
WHEN a3.shipped_qty1 > a4.shipped_qty2 AND a1.min1 < a2.min2 THEN "KEEP"
WHEN a3.shipped_qty1 < a4.shipped_qty2 AND a1.min1 < a2.min2 THEN "MOVE TO**a3.supplier**"
WHEN a3.shipped_qty1 > a4.shipped_qty2 AND a1.min1 > a2.min2 THEN "MOVE TO**a4.supplier**"
WHEN a3.shipped_qty1 < a4.shipped_qty2 AND a1.min1 > a2.min2 THEN "KEEP"
ELSE "NOT SHIPPING"
END) AS move
我该如何编写代码?
1条答案
按热度按时间sqougxex1#
你可以用
CONCAT()
要生成输出字符串:p、 我还把供应商的价值 Package 在
COALESCE()
因为我不知道这些列是否可以为null,否则如果这些值为null,查询将失败。