Menu
Coddy logo textTech

Recap - Junk

Part of the Fundamentals section of Coddy's SQL journey — lesson 72 of 72.

challenge icon

Challenge

Medium

Available tables and columns:

  • <strong>junk</strong>: <strong>junk_id</strong>

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 Fundamentals