SELECT  
CASE
    WHEN (Employees.End_Date is null) THEN select EmpId, Emp_Name, Salary , Start_date , End_date ,DATEDIFF(DATE_ADD(Start_Date, INTERVAL 30 DAY), Start_Date) * Salary/30 as 'Total_Salary' from Employees

    ELSE Select EmpId, Emp_Name, Salary , Start_date , End_date ,DATEDIFF(End_Date, Start_Date) * Salary/30 as 'Total_Salary' from Employees
END

From Employees;

Please help me to find error in this query. I

Do you really want to multiply the date difference by salary?
Everything else can be done more extensively without subqueries and without case when using simple IFNULL() function

SELECT EmpId, Emp_Name, Salary , Start_date , End_date ,
    DATEDIFF(
        IFNULL(End_date, DATE_ADD(Start_Date, INTERVAL 30 DAY))
        ,Start_Date
    ), Salary/30 as 'Total_Salary' from Employees
commented: Yes, please multiply my salary by the date. We'll all be millionaires in no time. +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.