ORDER BY criterion
Parte de la sección Fundamentos del Journey de SQL de Coddy — lección 58 de 72.
Una de las opciones de OVER () es la ORDER BY
Por ejemplo:
ROW_NUMBER() OVER (ORDER BY year DESC) as row_numEsto generará una columna que numerará las filas siguiendo el orden descendente del año.
Desafío
FácilTablas y columnas disponibles:
<strong>plants</strong>:<strong>id</strong>,<strong>hue</strong>,<strong>rough</strong>
Selecciona todas las plantas con un hue mayor que 0.34 y agrega dos columnas de numeración:
row_num_hue que numerará las filas según hue en orden ascendente
row_num_score que numerará las filas según la siguiente fórmula: rough*hue en orden descendente
Devuelve solo el id y las dos columnas de numeración. Ordena el resultado por el id de la planta en orden ascendente
Pruébalo tú mismo
Esta lección incluye un breve cuestionario. Empieza la lección para responderlo y registrar tu progreso.
Todas las lecciones de Fundamentos
4More Keywords
The IN keywordThe BETWEEN keywordThe LIKE keywordThe AS keywordRecap - Cellphone Models2Conditions
Conditions BasicsThe AND keywordThe OR keywordThe NOT keywordMultiple Conditions CombinedParenthesisBooleans5Arithmetic Operations
Mathematical OperatorsMathematical ColumnsThe Modulo OperationThe ROUND() Function8Statistics
Built-In Aggregate Part 1Built-In Aggregate Part 2Grouping Part 1Grouping Part 2Subqueries Part 1Subqueries Part 2Recap - Total Gain ShopRecap - Scooter ShopRecap - Coffee Shop11Window Functions part 1
ROW_NUMBER functionORDER BY criterionPARTITION BY criterionPARTITION & ORDERLEAD & LAG FunctionsRecap - LEAD & LAGRecap - PicturesRecap - Boxes3Specific Return Format
Null valuesSort Results Part 1Sort Results Part 2Recap - Cyber Security FirmLimit number of recordsRecap - Vehicle Factory6Intro Challenges
Recap - Parliamentary ElectionRecap - Police Criminal ArrestRecap - Bar Beverage ContainerRecap - Engineer new columns