Error on this Query:
SELECT 
    p.id,
    p.name,
    p.date,
    p.code,
    p.category,
    p.brand,
    p.tax,
    p.group_name,
    p.disclaimer,
    p.dealor_price,
    p.customer_price AS original_customer_price,

    COALESCE(sg.discount::numeric, 0) AS discount,

    ROUND(
      p.customer_price 
      - (p.customer_price * COALESCE(sg.discount::numeric, 0) / 100),
      2
    ) AS final_customer_price,

    MIN(m.media_id) AS image

FROM products p
LEFT JOIN product_photo m ON p.id = m.product_id
LEFT JOIN stock_group sg ON sg.name = p.group_name

GROUP BY 
    p.id, p.name, p.date, p.code, p.category, p.brand, 
    p.tax, p.group_name, p.disclaimer, 
    p.dealor_price, p.customer_price, sg.discount

ORDER BY p.name ASC
ERROR: invalid input syntax for type numeric: ""