Two query logistic error problem.

D

Dawn

Problem1:
Three tables:
T1:customer(200804),field:customerid(pk)
T2:account(200804),field:accountNo(pk), customerid,accountbalance
T3:account(200803),field:accountNo(pk), customerid,accountbalance
Method1:
In one query:
simultaneous inner join t1. customerid=t2. customerid and
t1. customerid=t3. customerid ,
output:sumof(t2. accountbalance), sumof(t3. accountbalance)
group by t1. customerid,

method2:
in two query:
query1: inner join t1. customerid=t2. customerid sum (t2. accountbalance)
group by t1. customerid,
query2: inner join t1. customerid=t3. customerid sum (t3. accountbalance)
group by t1. customerid,

After check ,the result of method2 is correct, the result of method1 is
several times of the the result of method2.

Problem2:
One table:
Three field: ’Branch name’, ‘customerid’, ‘customer-net-change-balance’
Sql1:
SELECT table1.[Brch Name], Sum(table1. customer-net-change-balance),
Count(table1.[Customerid])
FROM table1
GROUP BY table1.[Brch Name]
HAVING (((Sum(table1.minus1))>=0));

The summed up result is less than to those when copy all data of table1 to
excel, then run the filter enter the condition that
customer-net-change-balance>=0

But sql2:
SELECT Query1.[Brch Name], Sum(Query1.minus1) , Count(Query1.[HUB Cust Id])
FROM Query1
GROUP BY Query1.[Brch Name];
The result of sql2 is equal to those when copy all data of table1 to excel,
then take the function sum.

Can you explain why I am wrong?
Thanks.
Dawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top