Challenge: Prevent Division by Zero
Uppgift
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
bonuscolumn 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
NULLIFto avoid division by zero, and assign the result an alias.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 5. Kapitel 6
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Fantastiskt!
Completion betyg förbättrat till 2.86
Challenge: Prevent Division by Zero
Svep för att visa menyn
Uppgift
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
bonuscolumn 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
NULLIFto avoid division by zero, and assign the result an alias.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 5. Kapitel 6
single