gleb-ehorich / SQL

0 stars 0 forks source link

select #1

Open gleb-ehorich opened 1 year ago

gleb-ehorich commented 1 year ago

select * from ASRTBL where ASRTBL.kmat in ('T02811100000019', 'T02811100000018', 'T02811100000018', 'T02811100000016', 'T02811100000027')

gleb-ehorich commented 1 year ago

select * from ASRTBL where ASRTBL.CEH in ('73557', '73414', '73419')

gleb-ehorich commented 1 year ago

select * from ASRTBL_ where exists ( select 1 from pod left join podp on podp.ceh = pod.ceh and PODP.DATE_FROM = ( select max(p1.DATEFROM) from PODP as p1 where p1.CEH =POD.CEH ) where pod.ceh = ASRTBL.ceh and podp.kobj = '00001' and ASRTBL_.kmat in ('T01312200000171')

gleb-ehorich commented 1 year ago

select ASRTBL.kmat, ASRTBL.ceh, pod.kobj from ASRTBL left join pod on astrbl.ceh = pod.ceh where pod.kobj = '00001' and ASRTBL_.kmat in ('T01112200000001','T01112500000001','T01121300000002','T01121300000003')

gleb-ehorich commented 1 year ago

update ASRTBL set ASRTBL.SALBLOCK = 0 where ASRTBL.MTRXCODE = 3 and ASRTBL.CEH in ('72183', '73645', '73646', '73643', '73634', '73648', '73647', '73655', '73661', '73651', '3559', '3588', '3561', '3557', '3562', '3564', '3565', '3556', '3551') and ASRTBL.kmat in ('T02314100000030', 'T02522300000002', 'T01331100000003')

gleb-ehorich commented 1 year ago

delete from ASRTBL left join pod on pod.ceh = ASRTBL.ceh left join podp on podp.ceh = pod.ceh and PODP.DATE_FROM = (select max(p1.DATEFROM) from PODP as p1 where p1.CEH =POD.CEH) where podp.kobj = '00001' and ASRTBL.kmat in ('T01312200000171')

gleb-ehorich commented 1 year ago

update ASRTBL set KOBJ = (select KOBJ from PODP where PODP.CEH = ASRTBL.CEH and PODP.DATE_FROM = (select max(DATEFROM) from PODP p1 where p1.CEH =PODP.CEH)) update ASRTBL set INDEX = (select INDEX from POD where POD.CEH = ASRTBL.CEH) update ASRTBL set PRGRP = (select asrmtrx.prgrp from asrmtrx where asrmtrx.id = asrtbl.mtrxcode)

gleb-ehorich commented 1 year ago

Select distinct pod.index_, pod.ceh, podp.date_from, podp.ceh_name, podp.KBLS, podp.BS_Z, podp.GKAU_Z, podp.NAIM_P, podp.NAIM_PS, podp.NAIM_PS2, podp.KOBJ, podp.N_KDK_NACH, podp.N_KDK_UMC, podp.N_KDK_OS, podp.N_KDK_LOW, podp.PR_REZ, podp.ORG_GNI, podp.N_KDKHR, podp.KATOTTG, podp.SQUARE, podp.KKSV5, podp.MRPAU_ from pod left join podp on podp.ceh=pod.ceh and podp.date_from = (select max(p.date_from) from podp p where p.ceh = pod.ceh) order by podp.date_from desc