Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Prevent Division by Zero | Null Functions
Functions in SQL
Sectionย 5. Chapterย 6
single

single

bookChallenge: Prevent Division by Zero

Swipe to show menu

Task

Swipe to start coding

Write a query to calculate the total bonus, the number of employees, and the average bonus per employee. Use NULLIF to prevent division by zero when calculating the average bonus per employee.

  • Calculate the sum of the bonus column and assign it an alias.
  • Count the number of employees and assign it an alias.
  • Divide the total bonus by the number of employees using NULLIF to avoid division by zero, and assign the result an alias.

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ย 6
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt