Tools to use
Lesson 2 of 3 in Coddy's SQL Challenges pack #2 course.
Challenge
MediumTo build a castle the builder needs to have many tools. It is difficult to understand which tools he should use and in which order to use them. For that, we will extract the important information and help the builder create his castle.
Now the builder has a strength table that indicates the number of points he has to handle the tools every hour. Each hour he can use each tool once, and he should use as many tools as he can every hour. A tool difficulty is the number of points the builder is using.
Return the hour, points and the points he used that hour - call this column used
Try it yourself
SELECT name, difficulty, SUM(difficulty) OVER (ORDER BY row_num ASC) as tot_until_now
FROM (
SELECT name, difficulty, ROW_NUMBER() OVER (order by difficulty asc) as row_num
FROM tools
)
order by difficulty