Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Quiz
13. INSERT INTO with CTE
Summary

Instruction

Perfect! How about a slightly more complicated example with INSERT INTO?

Exercise

We've created another table called project_worktime. It has the following columns: project_id and avg_worktime.

Your task is to use the table allocation and insert the average number of hours spent on each project into the new table project_worktime. Each time, insert the project_id and the average hours_spent. Additionally, do not insert any data for project_id = 1.

Stuck? Here's a hint!

You'll need two CTEs:

  1. to get the sum of hours spent by a given user on a given project, and
  2. to get the average sum of hours per project based on a result of a first CTE.