Я создаю запрос, используя CASE WHEN, и я заявляю в 1 CASE, используя функцию IS NULL. Но результат запроса все еще возвращает значения NULL.
Ниже мой запрос
SELECT
CASE
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Customer membatalkan pesanan' THEN 'Customer canceling order'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Deskripsi dalam order tidak sama' THEN 'Description not match'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Barang rusak' THEN 'Item defective'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Salah satu barang rusak' THEN 'Partially defective'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Salah satu stok tidak tersedia' THEN 'Partially not available'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Stok tidak tersedia' THEN 'Stock not available'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Order tidak bisa di scan' THEN 'Cannot scan order'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Order belum dibayar' THEN 'Order not paid'
WHEN b.failure_detail IS NULL THEN 'Fulfillment Timeout'
END AS 'Cancellation Remarks',
COUNT(*) as 'Total'
FROM
deli_order A
INNER JOIN
deli_order_store B ON B.deli_order_id = A.id
WHERE
(DATE(A.plat_create_time) BETWEEN '2019-04-21' AND '2019-04-27') AND
(A.status = 8) AND
(A.pay_state = 1) AND
NOT EXISTS (
SELECT 1
FROM deli_order AS B
WHERE B.order_code = A.order_code
AND B.code = A.code
AND B.status = 6)
GROUP BY
CASE
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Customer membatalkan pesanan' THEN 'Customer canceling order'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Deskripsi dalam order tidak sama' THEN 'Description not match'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Barang rusak' THEN 'Item defective'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Salah satu barang rusak' THEN 'Partially defective'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Salah satu stok tidak tersedia' THEN 'Partially not available'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Stok tidak tersedia' THEN 'Stock not available'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Order tidak bisa di scan' THEN 'Cannot scan order'
WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(B.failure_detail, '"remark":"', -1), '"', 1) = 'Order belum dibayar' THEN 'Order not paid'
WHEN b.failure_detail IS NULL THEN 'Fulfillment Timeout'
END;
и это результат моего запроса
Cancellation Remarks | Total
NULL 35
Description not match 1
Fulfillment Timeout 19
Item defective 6
Stock not available 13
Что-то не так с моим запросом?