Final challenge #1
Lesson 13 of 13 in Coddy's SQL for advanced course.
Challenge
MediumIn this challenge, we have a junk table.
For each junk_id we would like to add the following columns:
even_num- row number from 2 to2*n(nis the number of rows in the table) in jumps of 2: 2, 4, 6, 8, etc., ordered byjunk_idnum_piece- represents a group (usingNTILE) that goes from 3 to 9 in jumps of 3: 3, 6, 9 (only 3 groups).avg_id- the average id of the current row and the 2 rows before it only in the same grouppiece_rank- dense rank of each group order by theavg_id
Try it yourself
All lessons in SQL for advanced
4Summary
Final challenge #13Window Functions part 2
RANK & DENSE_RANK functionsNTILE functionAggregation functionsROWS & RANGE criterion