Having these 4 tables:
TB_CAT_PRODUCTO (id_cat,nom_cat)
TB_PRODUCTO (id_pro,nom_pro,id_cant)
TB_PEDIDO (id_ped,fecha_ped
DETALLE_PEDIDO (id_ped,id_pro,cantidad,importe)
How would you find the best-selling product by category in a time interval?
Having these 4 tables:
TB_CAT_PRODUCTO (id_cat,nom_cat)
TB_PRODUCTO (id_pro,nom_pro,id_cant)
TB_PEDIDO (id_ped,fecha_ped
DETALLE_PEDIDO (id_ped,id_pro,cantidad,importe)
How would you find the best-selling product by category in a time interval?
Look at this example:
For a table with cat, prod, quantity you can do it like this:
select max(suma),cat from
(select sum(cantidad) as suma, cat, pro from tabla group by cat,pro) as x
In your case you must build the internal select by joins between your tables.