i have error on my sql query.
my query :
SELECT sum(billsItems_Quantity) as TotalQ ,
sum(billsItems_ItemDiscount) as TotalD ,
sum(billsItems_ItemTotal) as TotalI ,
bills.bills_ID ,
billsitems.billsItems_BillItemSerial ,
bills.bills_CashierID ,
bills.bills_StoreID ,
billsitems.billsItems_Unit ,
billsitems.billsItems_Price
FROM bills , billsitems
WHERE bills.bills_ID = billsitems.billsItems_BillItemSerial
and bills.bills_CashierID = '".$id."'
and bills.bills_StoreID = '$ausers_StoreId'
order by billsitems.billsItems_Unit
In my query I need to get sum of billsItems_Quantity , billsItems_ItemDiscount billsItems_ItemTotal by use sum function , in the same query I need to get all item of the table.
the error :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
Ok I think I understand your problem. Are you usign SQL Server 2005 or newer?
If so, you can do this with the “OVER” clause, wich will let you do sums and get all the other columns. here’s a way to do this