Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Calculate Average Bonus | Null Functions
Functions in SQL

bookChallenge: 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 COALESCE function to replace any NULL value in the bonus column with zero.
  • Calculate the average of these values.
  • The result should be a single column named avg_bonus.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 5
single

single

Ask AI

expand

Ask AI

ChatGPT

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?

close

bookChallenge: 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 COALESCE function to replace any NULL value in the bonus column with zero.
  • Calculate the average of these values.
  • The result should be a single column named avg_bonus.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 5
single

single

some-alt