There is a script that displays two tables. Names of type String and counting of type Long. How can I combine the same fields “Out of stock” in one field and separate fields “marriage”, “re-sorting” in one field “marriage / re-sorting” in one table. In doing so, save the types of two tables and get the combined values in the new fields. And how not to display extra fields, for example, a form for employees, etc. I know that you can use the CASE, WHEN, THEN structure. But I don’t understand how to correctly describe it in my script.
SELECT rl.reason AS reject_reason, COUNT(*)
FROM
mp.reservation_log AS rl
JOIN
mp.store AS st ON rl.store_id = st.md_id
JOIN mp.order_item oi ON oi.reserve_id=rl.reservation_id
JOIN mp.sku s ON s.id=oi.item_id
JOIN mp.product p ON p.id=s.product_id
WHERE rl.created_at > DATE(NOW()) - INTERVAL 1 MONTH AND rl.is_successful=0
GROUP BY rl.reason;
Table example: