Подскажите есть задача выбрать размер упаковки товара.
Возникла проблема когда контрактов 2 или больше.
Пробовал выбрать так:
Код:
SELECT TO_CHAR(P.PACKSIZE) AS PACKSIZE,
TO_CHAR(D.CREATEDAT, 'DD.MM.YY') AS DOC_D,
L.LOCATIONID
FROM SUPERMAG.SMSPECCO P,
SUPERMAG.SMDOCUMENTS D,
SUPERMAG.SMCONTRACTLOCATIONS L
WHERE P.DOCID = D.ID
AND P.DOCTYPE = D.DOCTYPE
AND D.ID = L.ID
AND 'CQ' = L.DOCTYPE
AND '1000115' = P.ARTICLE
AND 1 = L.LOCATIONID
AND 3 = D.DOCSTATE
AND L.ID = P.DOCID
ORDER BY D.CREATEDAT DESC
Но Т.К. строк несколько как его подключить к основному запросу ?
основной запрос:
Код:
SELECT
D.ID AS DOCID,
D.CREATEDAT AS CREATEDAT,
DT.DATEDAT AS DARTDAT,
DT.DATEDAT2 AS DATEDAT2,
P.PARAMVALUE AS COM,
CL.NAME AS POSTAVSHIK,
C.ARTICLE AS ARTICLE,
SP.SUPPLIERARTICLE AS SUPPLIERARTICLE,
SUPERMAG.barToStrcreate(S.ARTICLE) BARCODE,
C.NAME AS NAME,
S.QUANTITY AS QUANTITY
FROM SUPERMAG.SMDOCUMENTS D
LEFT JOIN SUPERMAG.SMDATEDOCS DT ON DT.ID=D.ID AND DT.DOCTYPE=D.DOCTYPE
LEFT JOIN SUPERMAG.SMDOCPROPS P ON P.DOCID=D.ID AND P.DOCTYPE = D.DOCTYPE AND P.PARAMNAME='CustomLabels.DOPCOMMENT'
LEFT JOIN SUPERMAG.SMSPEC S ON S.DOCID = D.ID AND D.DOCTYPE = S.DOCTYPE
LEFT JOIN SUPERMAG.SMCARD C ON C.ARTICLE = S.ARTICLE
LEFT JOIN SUPERMAG.SMCLIENTINFO CL ON CL.ID = D.CLIENTINDEX
LEFT JOIN SUPERMAG.SMSUPPLYCASE SP ON SP.ARTICLE = S.ARTICLE AND SP.IDSUPPLIER = D.CLIENTINDEX
WHERE
D.ID = 'ЗП1488798'
AND D.DOCTYPE IN ('OR','SO')