Tengo la siguiente consulta:
SELECT pr_products.product AS PRODUCT, pr_varieties.variety AS VARIETY, pr_grades.GRADE, SUM(pf_harvest.quantity) AS QUANTITY
FROM pf_harvest
INNER JOIN pf_performance ON pf_performance.id = pf_harvest.id_performance
INNER JOIN pr_products ON pr_products.id = pf_harvest.id_product
INNER JOIN pr_varieties ON pr_varieties.id = pf_harvest.id_variety
INNER JOIN pr_grades ON pr_grades.id = pf_harvest.id_grade
WHERE pf_performance.status = 100
AND pf_harvest.id_tenant = 1
AND pf_harvest.date = '2017-03-22'
GROUP BY pf_harvest.id_product, pf_harvest.id_variety, pf_harvest.id_grade
ORDER BY pf_harvest.id_product, pr_varieties.variety, pf_harvest.id_grade;
que me muestra el siguiente resultado:
-------------------------------------------------------------------
PRODUCT | VARIETY | GRADE | QUANTITY |
-------------------------------------------------------------------
ROSE | ROSEV1 | GRADE1 | 1000 |
-------------------------------------------------------------------
ROSE | ROSEV1 | GRADE2 | 5000 |
-------------------------------------------------------------------
ROSE | ROSEV2 | GRADE1 | 2000 |
-------------------------------------------------------------------
ROSE1 | ROSE1V1 | GRADE1 | 3500 |
-------------------------------------------------------------------
es posible mostrar el resultado de la consulta de la siguiente manera?
-------------------------------------------------------------------
PRODUCT | VARIETY | GRADE1 | GRADE2 | TOTAL |
-------------------------------------------------------------------
ROSE | ROSEV1 | 1000 | 5000 | 6000 |
-------------------------------------------------------------------
ROSE | ROSEV2 | 2000 | 0 | 2000 |
-------------------------------------------------------------------
ROSE1 | ROSE1V1 | 3500 | 0 | 3500 |
-------------------------------------------------------------------
he intentado cambiar la consulta pero no he podido y quisiera saber si es posible, espero que alguien me pueda ayudar.
gracias