SELECT o.orderid, o.orderstatus, o.custom_field_catdepartment, o.custom_field_catstatus, o.custom_field_catreason, o.ordernotes
FROM orders o
JOIN payment_log pl ON o.orderid = pl.pay_orderid
WHERE YEAR(o.orderdate) = 2024 AND
pl.pay_result = 'CREDIT'