Challenge: Calculate Average Bonus
Task
Swipe to start coding
Write a query to calculate the average bonus for all employees in the employees table, treating any NULL bonus values as zero.
- Use the
COALESCEfunction to replace anyNULLvalue in thebonuscolumn with zero. - Calculate the average of these values.
- The result should be a single column named
avg_bonus.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 5
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Can you explain that in more detail?
What are the main benefits or drawbacks?
Can you give me an example?
Awesome!
Completion rate improved to 2.86
Challenge: Calculate Average Bonus
Swipe to show menu
Task
Swipe to start coding
Write a query to calculate the average bonus for all employees in the employees table, treating any NULL bonus values as zero.
- Use the
COALESCEfunction to replace anyNULLvalue in thebonuscolumn with zero. - Calculate the average of these values.
- The result should be a single column named
avg_bonus.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 5
single