Hola a todos.
Finalmente mi consulta, para generar mi tabla, con los elementos a CERO y ordenados y agrupados como necesito es la siguiente:
Código MySQL:
Ver originalSELECT t_applications.APPLICATION_ID
, t_applications.APPLICATION_name_spanish
, t_materials.MATERIAL_ID
, t_materials.MATERIAL_name_spanish
, count(t_products_materials.PRODUCT_ID
) LEFT JOIN t_products_applications
ON t_products_applications.APPLICATION_ID
= t_applications.APPLICATION_ID
LEFT JOIN t_products_materials
ON t_products_materials.PRODUCT_ID
= t_products_applications.PRODUCT_ID
AND t_products_materials.MATERIAL_ID
= t_materials.MATERIAL_ID
GROUP BY t_applications.APPLICATION_ID
, t_applications.APPLICATION_name_spanish
, t_materials.MATERIAL_ID
, t_materials.MATERIAL_name_spanish
ORDER BY t_applications.APPLICATION_name_spanish
ASC, t_materials.MATERIAL_name_spanish
ASC
Si le veis alguna manera de optimizarla, no dudéis en decírmelo.
Saludos.
Javier