Skip to Content
May 07, 2012 at 12:58 PM

query for ORDR->OPOR->OPCH


hello to all!

i am interested in finding a query with which i will be able to fine the base document and the target document by inserting the docnum for the above tables

till now i have made the following code

select distinct t1.cardcode


,CASE when t4.Baseref is not NULL then t1.docnum Else NULL end as '# Εντολής Αγοράς'

, t1.docdate as 'Ημ/νία Καταχώρησης Εντολής'

,case when t5.trgetentry is not null then t1.docnum Else NULL end as '# Παραγγελία'

,t2.docdate as 'Ημ/νία Παραλαβής/Ήμ/νία Άφιξης'

from opor t1

inner join por1 t5 on t5.docentry = t1.docentry

inner join RDR1 t4 on t5.TrgetEntry =t4.docentry

inner join ORDR t2 on t4.docentry = t2.docentry

where --t5.TargetType = '18' and

--t1.cardcode ='80000' AND


but it does not work properly. actually it brings me the ordr.docnum but the opor.docnum is wrong

do you have any idea?

thanks a lot for your time!