Skip to content

Instantly share code, notes, and snippets.

@Marian0
Created December 19, 2014 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marian0/dac25364716861ac0b5e to your computer and use it in GitHub Desktop.
Save Marian0/dac25364716861ac0b5e to your computer and use it in GitHub Desktop.
Consulta para obtener productos con precio menor al de compra
select * from
product P,
(SELECT idProduct as prodStock, max(unitPrice) as maxPrice from buy B where stockAvailable>0 GROUP BY idProduct) L
WHERE
P.idProduct=prodStock
AND
P.unitSellingPrice<=maxPrice
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment