Error on this Query:
SELECT
p.*,
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,
(
SELECT m.media_id AS image
FROM product_photo m
WHERE m.product_id = p.id
LIMIT 1
) AS image
FROM products p
LEFT JOIN stock_group sg ON sg.name = p.group_name
WHERE 1=1ERROR: invalid input syntax for type numeric: ""