Menu
Coddy logo textTech

Final challenge #1

Lesson 13 of 13 in Coddy's SQL for advanced course.

challenge icon

Challenge

Medium

In 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 to 2*n (n is the number of rows in the table) in jumps of 2: 2, 4, 6, 8, etc., ordered by junk_id
  • num_piece - represents a group (using NTILE) 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 group
  • piece_rank - dense rank of each group order by the avg_id

Try it yourself

All lessons in SQL for advanced