I tried to retrieve values from 2 tables (main (accounts), sub(account_Details)), which they are: acc_ID,acc_Name,acc_Place,acc_Date, total "total of debts-payment-returned". and i do it like this is below, but an error appear: "You tried to execute a query that does not include the specified expression acc_Name as part of an aggregate function. "
The Code:
select a.acc_ID,a.acc_Name,a.acc_Place,a.acc_Date, sum(b.acc_Sub_Debt)-sum(b.acc_Sub_Payment)+sum(b.acc_Sub_Returned) total from accounts a,account_Details b where a.acc_ID = b.acc_Sub_ID and total < 1000 group by a.acc_ID order by a.acc_ID asc