SQL Multiplication query

mysql, sql, sum

Solution

You can use alias names only in later clauses of a query and not in the select clause itself. Use

SELECT `Daily_Charge`,
        DATEDIFF(End_Date,Start_Date) AS `Total`, 
        DATEDIFF(End_Date,Start_Date) * Daily_Charge AS `Done`
FROM `Car`,`Contract`
WHERE `Contract_Id`='1';

Problem

I'm trying to do a multiplication sum but can't seem to find out why it's not working. I've found the amount of days, but now need to multiply this by the daily charge. Can anyone help? ``` SELECT `Daily_Charge`, DATEDIFF(End_Date,Start_Date) AS `Total`, `Total`*Daily_Charge AS `Done` FROM `Car`,`Contract` WHERE `Contract_Id`="1"; ```

Original source