jeudi 15 février 2018

what should i use if i want to update my record if a certain condition its true

i want to update my records, if the day of the last payment of the client its greater than 100;

 update clients set ind_mo = 2,
ind_pay=2

if its less than 100;

update clients set ind_mo = 1, 
ind_pay = 1

if the the own of the client its = 0

update clients set ind_mo = 1,
ind_pay = 1 

i already tried this but it does not update my record if the own its 0

if (datediff(day,((select top 1 fec_ven from 
cxc_cuedoc  cue inner join cxc_cliente cli
on cli.cod_cli = cue.cod_cli  where sal_doc !=0 and cue.tip_doc = '010'  and num_doc=cue.num_doc)),getdate())) > 110
update cxc_cliente
 set ind_mora ='2',
IND_JURIDICO = '2';
else
update cxc_cliente
set ind_mora = '1',
ind_juridico ='1'

Aucun commentaire:

Enregistrer un commentaire