Click here to Skip to main content
15,909,332 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I ran this simple code from both Access 97 and SQL SERVER 2005. In Access I received 12285 records and in SQL Server I received 17115 records. I s there anyone That knows what is wrong with this simple code??? Or do you have any ideas?

SELECT A.CUS_NUM_AR,A.INS_CO_AR,A.APPLY_TO_AR,AT.AttributeID,<br />
<br />
SUM(A.TOTALAMOUNT) AS 'Total Amount'<br />
FROM AR700.dbo.tblAROPEN A<br />
<br />
INNER JOIN LMSDATA.dbo.tblCustomerAttribute AT<br />
<br />
ON A.CUS_NUM_AR = AT.CustomerNumber<br />
<br />
WHERE A.INS_CO_AR IN ('0','000')<br />
<br />
AND AT.AttributeID = 3  <br />
AND A.TOTALAMOUNT >0 <br />
<br />
GROUP BY A.CUS_NUM_AR,A.INS_CO_AR,A.APPLY_TO_AR,AT.AttributeID<br />
<br />
ORDER BY A.CUS_NUM_AR
Posted
Updated 20-Jul-11 7:53am
v3

1 solution

Try
SELECT 
   A.CUS_NUM_AR,
   A.INS_CO_AR,
   A.APPLY_TO_AR,
   AT.AttributeID,
   SUM(A.TOTALAMOUNT) AS 'Total Amount'
 FROM AR700.dbo.tblAROPEN A
 INNER JOIN LMSDATA.dbo.tblCustomerAttribute AT
   ON (A.CUS_NUM_AR = AT.CustomerNumber AND AT.AttributeID = 3)
 WHERE 
   A.INS_CO_AR IN ('0','000')
 AND 
   A.TOTALAMOUNT >0
 GROUP BY A.CUS_NUM_AR,A.INS_CO_AR,A.APPLY_TO_AR,AT.AttributeID
 ORDER BY A.CUS_NUM_AR


I just added parenthesis on the JOIN, not that I think it will help

I'm fairly certain I wouldn't trust Access 97 for anything ...
Bug: Records disappear when you sort them[^]

Best regards
Espen Harlinn
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900