You are managing a database of employees with their ID, Name, Salary, and optional Bonus fields. To calculate each employee's total pay (salary plus bonus), you are writing an SQL query. You've noticed that some bonuses are not set (NULL), which is causing some issues. Fill in the blanks in the provided code to adjust the calculation so if an employee's bonus is set to NULL, the query should consider it as zero when calculating the total pay.
The NULL value
Calculating total pay considering NULL bonuses as zero
Report a typo
Fill in the gaps with the relevant elements
Employees (
ID INT PRIMARY KEY,
Name VARCHAR(255) NOT ,
Salary DECIMAL(10, 2) NOT NULL,
Bonus DECIMAL(10, 2) NULL
);
INSERT INTO Employees (ID, Name, Salary, Bonus)
VALUES (1, 'John Doe', 5000.00, NULL);
SELECT ID, Name, Salary + IFNULL(Bonus, 0) AS TotalPay
FROM Employees;Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.