Recap - Junk
Part of the Fundamentals section of Coddy's SQL journey — lesson 72 of 72.
Challenge
MediumAvailable 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 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 Fundamentals
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() Function3Specific 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