如果列(cant_pallets_completo)的值为0,则替换另一列的值(cant_sku)
SELECT SUM(cant_pallets_completo) AS 'volumen_de_pallets'
FROM estadistica_productividad_picking_rf
WHERE cd='faseSQL' AND c_emp_user_grua <> '' ;
谢谢!
答案 0 :(得分:1)
如果是SQL服务器,您可以尝试:
SELECT SUM(CASE WHEN cant_pallets_completo = 0
THEN cant_sku
ELSE cant_pallets_completo END) AS 'volumen_de_pallets'
FROM estadistica_productividad_picking_rf
WHERE cd='faseSQL' AND c_emp_user_grua <> '' ;