I'm making a query to calculate the summation of total and amount columns but with the calculation of raw-materials and growth profit, I get the raw-materials summation from the items table that has the price in it and calculate the growth profit by subtracting calculated raw-materials from the amount,
The problem comes when I run the query it gives me wrong values. like sum of amount
sum(`payment`.`amount`) as total amount
should be like 1425 but the result is 107100, I don't know why it does this in the image below I showed the results, that number 107100 it way more than it should be please I’m new someone help me
This is my query
select `payment`.`date` as `Date`,
sum(`payment`.`total`) as `Total`,
sum(`payment`.`amount`) as `Paid amount`,
sum(items.price) as `R.M`,
sum(`payment`.`amount`) - sum(items.price) AS `G.P`,
`currennt_exp`.`expence` as `Current Expenses`,
sum(`payment`.`amount`)-sum(items.price) - `currennt_exp`.`expence` AS `Revenue`
from `payment`,`paymen_information`,`bill_information`,`bills`,`items`,`currennt_exp`,`appointments`
where `payment`.`id_payment` = `paymen_information`.`id_payment` and `paymen_information`.`id_bill` = `bills`.`id_bill` and bill_information.bills_id = `bills`.`id_bill` and bill_information.item_id = `items`.`id_item` and
date_format(`payment`.`date`,'%Y-%m-%d') = date_format(`currennt_exp`.`_date`,'%Y-%m-%d') and
date_format(`payment`.`date`, '%Y-%m-%d') = CURDATE()
and this is my table
total amount
135.0000 135.0000
165.0000 165.0000
375.0000 375.0000
300.0000 300.0000
450.0000 450.0000
and this is the result and its very wrong