How use MAX in mysql to get follow result

This is the query

SELECT 
 research_id,
 IF(product_id = 4, IF(value REGEXP '^-?[0-9]+$' > 0, value, IF(value = 'Yes', 1, 0)), 0) AS val1,
 IF(product_id = 8, IF(value REGEXP '^-?[0-9]+$' > 0, value, IF(value = 'Yes', 1, 0)), 0) AS val2 FROM
research_product_details rpd
    LEFT JOIN
products p ON rpd.product_id = p.id WHERE
(product_id = 4 AND value >= 50) or (product_id = 8 AND value >= 50) ORDER BY research_id ASC , product_id ASC

And i got this result from this query

enter image description here

i want it like follow

enter image description here


Source: mysql

Leave a Reply