Thanks for the quick answers! Still trying to figure out how to put all this together.
So this sql is a part of different sql's that we use in a software that put together information that are being printed on labels for different packages from orders. When we prreview the labels in the software we just put in the specific package ID and then it fetches all the sql and shows the info on the label.
This is the sql thats already written by someone else.
-
This Sql counts the packages on specific orders. O04T2 = table for all the packages
SELECT COUNT(0) antalKollin FROM O40T2
WHERE shortr08 IN
(SELECT shortr08
FROM O40T2
WHERE ocarrno = @:ocarrno)
-
Then there's also this sql, the last line on this sql also contains (where O40T2.ocarrno = @:ocarrno) thats included in the sql above. So I guess they have some kind of connection
select O40T2., R08T1., R04T1., O04T1.custno o04_custno, O04T1., SHIPTO., ASTRO_VIEW_TBL_OEPARTY.
from O40T2
left join R08T1 on R08T1.shortr08 = O40T2.shortr08
left join R04T1 on R04T1.routeno = R08T1.routeno
left join O06T1 on O06T1.shorto06 = O40T2.shorto06
left join O04T1 on O04T1.shorto04 = O06T1.shorto04
left join (select d13obj td13obj, sysshort tsysshort, roletype troletype,
d10name1 tname1, d50adrs1 taddressline1, d50adrs2 taddressline2, d50adrs3 taddressline3, d50zipc tpostal, d50city tcity, d50cntry tcountry
from D13T1
join D10T1 on D10T1.shortd10=D13T1.shortd10
join D50T1 on D50T1.adrid= D10T1.adrid ) SHIPTO
on SHIPTO.tsysshort=O40T2.ocarrno and SHIPTO.td13obj=170 and SHIPTO.troletype=5
left join ASTRO_VIEW_TBL_OEPARTY ON ASTRO_VIEW_TBL_OEPARTY.d13obj = 20 and ASTRO_VIEW_TBL_OEPARTY.sysshort = O06T1.shorto04
where O40T2.ocarrno = @:ocarrno