Hi , I have 5 quries, each query showing expense of different category.
like Lease,Diesel,Security,Electricity, Maintenance. 3 quries using 6 tables and 2 quries using 2 tables means 6 tables used in total. Now I want To Show Expense Using one query so I can Get complete Sum of Expenses.
Here are my All Queries
Diesel: (Using 2 Tables Diesel info and Rates(its uesed in onother 2 quries also))
$result = mysql_query("SELECT FORMAT(ROUND( Qty * Itemrate ),2) FROM `diesel_info`
INNER JOIN rates ON diesel_info.marker = rates.item
AND MONTH( diesel_info.Date ) = MONTH(rates.Date )
WHERE diesel_info.Code =$a AND MONTH( diesel_info.Date )=$m ");
$row = mysql_fetch_array($result);
echo $row[0];
Lease: (USING ONE Table lims_payment)
SELECT FORMAT(ROUND(SUM(`Amount`/12)),2)
FROM `lims_payment`
WHERE `Code` =$a AND YEAR(DurationS)=$y
Electricity: (Table name is eims_center)
$result = mysql_query("SELECT FORMAT(`GrossAmountWD`,2) FROM `eims_center`
WHERE `Code` =$a AND `BillMonth`='$me'");
$row = mysql_fetch_array($result);
echo $row[0];
Security:(Table Name is securityguards and other table is rates used 2nd time)
$result = mysql_query("SELECT FORMAT(Rates.ItemRate,2) FROM securityguards INNER JOIN rates ON securityguards.Company = rates.item
WHERE securityguards.SiteId =$a");
$row = mysql_fetch_array($result);
echo $row[0];
Outsourcing:(table 1 is info and second table is rates used 3rd time
$result = mysql_query("SELECT FORMAT(Rates.ItemRate,2) FROM info INNER JOIN rates ON info.MaintainedBy = rates.item WHERE info.Code =$a");
$row = mysql_fetch_array($result);
echo $row[0];
All these queries showing expense of each category but now i want to make one query which shows sum of result of all individual queries. creating temporary table is a better idea if any one knows. please suggest.