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
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Functions in SQL

bookChallenge: Prevent Division by Zero

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

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

Suggested prompts:

Can you explain this in simpler terms?

What are the main points I should remember?

Can you give me an example?

close

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

some-alt