MySQL Forums
Forum List  »  Spanish

Re: Combinar función MIN y GROUP BY
Posted by: Horacio Augusto Navarro García
Date: February 12, 2017 01:38AM

Despues de navegar un rato y buscar encontre un ejemplo que hacia lo que necesito y mi consulta que da el resultado que espero, es decir, los precios mínimos de todas las cotizaciones y el proveedor que lo ofrece quedo así:

Select d1.*,p.nombre As prodNom, pv.nombre As pvoNom From d_cotizacion As d1 Inner Join (Select d.id_Prod,Min(d.precio) As minPrecio From d_cotizacion As d Inner Join e_cotizacion As e On d.id_Cotiza=e.id Where e.id_Lista=37 Group By d.id_Prod) d2 On d1.id_Prod=d2.id_Prod And d1.precio=d2.minPrecio Inner Join productos As p On d1.id_Prod=p.codigo Inner Join e_cotizacion As e1 On d1.id_Cotiza=e1.id Inner Join proveedores As pv On e1.id_Pvo=pv.id

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Combinar función MIN y GROUP BY
124
February 12, 2017 01:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.