Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem With SELECT

radcaesar's Avatar
Moderator
 
Join Date: Sep 2006
Posts: 756
#1: Sep 22 '06
Hi All,
I Have Three Tables,

Customer
NewTransaction
Transactions

The Customer Table Have details about customer and the Transactions table had details of the transactions with gross amount and the

Transactions table had the Installment amounts for a particular transaction.

Now, i want the closed transactions i.e NewTransaction.GrossAmount=sum(Transactions.Inst_A mount)

My Query,

Code:
SELECT c.name AS [Customer Name], nt.tran_id AS [Transaction ID], nt.bill_number AS [Bill Number], nt.amount AS [Gross Amount], sum
(t.inst_amount) AS [Amount Received]
FROM customer AS c, newtransaction AS nt, transactions AS t
WHERE c.id=nt.id and c.id=t.customer_ID and nt.tran_id=t.transaction_id and nt.amount IN (SELECT sum(t.inst_amount) FROM
transactions AS t, newtransaction AS nt, customer AS c WHERE c.id=nt.id and c.id=t.customer_id and nt.tran_id=t.transaction_id GROUP
BY t.transaction_id)
GROUP BY c.name, nt.bill_number, nt.tran_id, nt.amount; I had a problem when there will be two equal gross amount.


Another record which was not closed also displayed, which has the same gross amount.

Solutions Pls.......

Reply