Попробуй такой запрос:
Код:
SELECT t_pr.article article,
t_pr.name name,
t_pr.cardcomment cardcomment,
t_pr.country country,
t_pr.price price,
(select sp.itemprice from supermag.smspec sp, supermag.smdocuments d, supermag.smauctions au
where sp.doctype='MA' and sp.doctype=d.doctype and sp.docid=d.id
and au.doctype=d.doctype and au.id=d.id and d.docstate>=2 AND au.datebegin >= TRUNC (SYSDATE)
AND &P_LOC IN (SELECT locid
FROM supermag.smauctionatoms am
WHERE am.aucid = d.id AND am.doctype = d.doctype) and sp.article=t_pr.Article)price_ma,
t_pr.qtyprint qtyprint,
t_pr.unitname unitname,
t_pr.isscale isscale,
t_pr.plu plu,
(select d.id from supermag.smspec sp, supermag.smdocuments d, supermag.smauctions au
where sp.doctype='MA' and sp.doctype=d.doctype and sp.docid=d.id
and au.doctype=d.doctype and au.id=d.id and d.docstate>=2 AND au.datebegin >= TRUNC (SYSDATE)
AND &P_LOC IN (SELECT locid
FROM supermag.smauctionatoms am
WHERE am.aucid = d.id AND am.doctype = d.doctype) and sp.article=t_pr.Article) ma_id,
(select TRUNC (au.datebegin) from supermag.smspec sp, supermag.smdocuments d, supermag.smauctions au
where sp.doctype='MA' and sp.doctype=d.doctype and sp.docid=d.id
and au.doctype=d.doctype and au.id=d.id and d.docstate>=2 AND au.datebegin >= TRUNC (SYSDATE)
AND &P_LOC IN (SELECT locid
FROM supermag.smauctionatoms am
WHERE am.aucid = d.id AND am.doctype = d.doctype) and sp.article=t_pr.Article) ma_datebegin,
(select TRUNC (au.dateend)from supermag.smspec sp, supermag.smdocuments d, supermag.smauctions au
where sp.doctype='MA' and sp.doctype=d.doctype and sp.docid=d.id
and au.doctype=d.doctype and au.id=d.id and d.docstate>=2 AND au.datebegin >= TRUNC (SYSDATE)
AND &P_LOC IN (SELECT locid
FROM supermag.smauctionatoms am
WHERE am.aucid = d.id AND am.doctype = d.doctype) and sp.article=t_pr.Article) ma_dateend
FROM supermag.svpricecard t_pr