>In the 2nd one, the outer records - i.e., the records for scorder table that don't match the records in the scordln table - are included in the results, and therefore in the sum.
>Add the bold line below to make the 2nd one behave like the first.
>
>
select sum(scordln.orl_qty-scordln.orl_qtyinvoiced) as nqty ;
> from scordln left outer join scorder ;
> on scordln.orl_order = scorder.ord_order ;
> where scorder.ord_acct < 201 ;
> <b>having !isnull(scorder.ord_acct)</b> ;
> into cursor cqty
>
I swear this worked when I tested it before I posted it yesterday, but I tried it again today and it didn't. I was surprised that it did work, because HAVING is supposed to only work with a GROUP BY.
Since the one with the BETWEEN() works - just go with that one. <s>
For a good explanation of what's happening, see Ed Rauh's response to me on the other thread. Message#
437085
Insanity: Doing the same thing over and over and expecting different results.