Skip to content

Instantly share code, notes, and snippets.

@ricardosiri68
Created June 1, 2015 22:24
Show Gist options
  • Select an option

  • Save ricardosiri68/8ee10fb66a550eb02b84 to your computer and use it in GitHub Desktop.

Select an option

Save ricardosiri68/8ee10fb66a550eb02b84 to your computer and use it in GitHub Desktop.
CREATE TABLE tabla_loca(
id int PRIMARY KEY AUTO_INCREMENT,
a int,
b int
);
INSERT INTO tabla_loca (a, b) VALUES
(1, 3),
(2, 1),
(1, 5),
(3, 2),
(2, 3),
(2, 6);
DELIMITER $$
CREATE PROCEDURE `seleccionar_mayores`()
BEGIN
SELECT a, max(b) FROM tabla_loca GROUP BY a;
END
$$
CALL seleccionar_mayores();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment