Úselo así:
SELECT
*,
COALESCE(b.customer_id, 0) AS customer_id
FROM sales_customer a
LEFT JOIN sales_contact b ON a.customer_id = b.customer_id
ORDER BY
CASE WHEN company_name = '' THEN lname ELSE company_name END ASC
Úselo así:
SELECT
*,
COALESCE(b.customer_id, 0) AS customer_id
FROM sales_customer a
LEFT JOIN sales_contact b ON a.customer_id = b.customer_id
ORDER BY
CASE WHEN company_name = '' THEN lname ELSE company_name END ASC