clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601446 fiddles created (47995 in the last week).

SELECT VERSION();
VERSION()
8.0.11
 hidden batch(es)


DROP TABLE IF EXISTS `alumnos`;
 hidden batch(es)


CREATE TABLE IF NOT EXISTS `alumnos` ( `nombre_a` VARCHAR(25) NOT NULL, `id_escuelas` BIGINT UNSIGNED NOT NULL );
 hidden batch(es)


INSERT INTO `alumnos` (`nombre_a`, `id_escuelas`) VALUES ('Juan', 1), ('Roman', 2), ('Raul', 3), ('Omar', 1), ('Jose', 2);
 hidden batch(es)


SELECT `x`.`nombre_a`, `x`.`id_escuelas` FROM ( SELECT `alumnos`.`id_escuelas`, `alumnos`.`nombre_a`, ROW_NUMBER() OVER(PARTITION BY `alumnos`.`id_escuelas`) AS `rank` FROM `alumnos` ) `x` ORDER BY `x`.`rank`, `x`.`id_escuelas`;
nombre_a id_escuelas
Juan 1
Roman 2
Raul 3
Omar 1
Jose 2
 hidden batch(es)