× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



i dont want to change unmatched records, but the way my code was heading i had 
to "deal" with them somehow, and subtracting zero would leave them unchanged.
  I have run your code and its just what i want.  The syntax you used for the 
inner join will help lots.
  Thanks.
  

rob@xxxxxxxxx wrote:
  First of all, why do you want to "subtract zero from unmatched records"? 
Why update them at all? Is it because if the record already has a 
negative number you want to change it to zero?

select * from dudstock
....+....1....+....2.
DSPROD DSLQSTS 
A 1.00 
B 1.00-
C 9,000,000.00 
D 800.00 

select * from crt
....+....1....+....
CODE QTY 
A 20.00 
C 40.00 

update dudstock
set dslqsts= 
case when dslqsts-(select qty 
from crt 
where dsprod=code)>0
then dslqsts-(select qty 
from crt 
where dsprod=code) 
else 0 
end 
where dsprod in (select dsprod 
from dudstock 
inner join crt 
on dsprod=code) 
2 rows updated in DUDSTOCK in QTEMP. 

select * from dudstock 
....+....1....+....2.
DSPROD DSLQSTS 
A .00 
B 1.00-
C 8,999,960.00 
D 800.00 


Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.