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
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