Цитата: "t.article, "+
"t.price, "+
"supermag.russianspell.PriceCardString(0, t.price) as grn, "+
"supermag.russianspell.PriceCardString(2, t.price) as kop, "+
"supermag.russianspell.PriceCardString(0, t.oldprice) as oldprice_grn, "+
"supermag.russianspell.PriceCardString(2, t.oldprice) as oldprice_kop, "+
"t.RubName, "+
"t.KopName, "+
"(select p.PropVal "+
" from supermag.SMCardProperties p "+
"where p.Article=t.Article "+
"and p.PropID='Sys.Composition') Composition, "+
"(select p.PropVal "+
" from supermag.SMCardProperties p "+
"where p.Article=t.Article "+
"and p.PropID='Sys.BrandName') BrandName, "+
"(select p.PropVal "+
" from supermag.SMCardProperties p "+
"where p.Article=t.Article "+
"and p.PropID='Vesy_number') Vesy_number, "+
"t.name, "+
"t.cardcomment, "+
"t.country, "+
"t.qtyprint, "+
"t.unitname, "+
"t.isscale, "+
"t.plu, "+
"t.price_ma, "+
"supermag.russianspell.PriceCardString(0, t.price_ma) as price_ma1, "+
"supermag.russianspell.PriceCardString(2, t.price_ma) as price_ma2, "+
"t.ma_id, "+
"t.ma_datebegin, "+
"t.ma_dateend "+
"FROM ( "+
"SELECT t_pr.article, "+
"(case when d.docstate=2 then "+
"ROUND(sp.itemprice*t_pr.qty, t_pr.priceprec) "+
"else "+
"t_pr.price "+
" end "+
") price, "+
"(case when d.docstate=2 then "+
" t_pr.price "+
"else "+
"(select ROUND(ph.price*t_pr.qty, t_pr.priceprec) "+
"from supermag.SMPriceHistory ph "+
"where (eventtime, recid) = "+
"(select max(eventtime), max(recid) "+
"from supermag.SMPriceHistory "+
"where article = ph.article "+
"and storeloc = ph.storeloc "+
"and pricetype = ph.pricetype "+
"and ROUND(price*t_pr.qty, t_pr.priceprec) != t_pr.price) "+
"and ph.storeloc = {0:N} "+
"and ph.article = t_pr.article "+
"and ph.pricetype = {1:N} "+
"and ROUND(ph.price*t_pr.qty, t_pr.priceprec) != t_pr.price) "+
"end "+
") oldprice, "+
"t_pr.RubName, "+
"t_pr.KopName, "+
"t_pr.name, "+
"t_pr.cardcomment, "+
"t_pr.country, "+
"t_pr.qtyprint, "+
"t_pr.unitname, "+
"t_pr.isscale, "+
"t_pr.plu, "+
"sp.itemprice price_ma, "+
"d.id ma_id, "+
"TRUNC (au.datebegin) ma_datebegin, "+
"TRUNC (au.dateend) ma_dateend "+
"FROM supermag.svpricecard t_pr, "+
" supermag.smdocuments d, "+
" supermag.SMSpecMA sp, "+
" supermag.smauctions au "+
"WHERE t_pr.article = sp.article "+
"AND d.doctype = 'MA' "+
"AND d.id = sp.docid "+
"AND d.doctype = sp.doctype "+
"AND t_pr.article = sp.article "+
"AND d.id = au.id "+
"AND d.doctype = au.doctype "+
"AND d.docstate >= 2 "+
"AND au.dateend > SYSDATE "+
"AND ({0:N},{1:N}) IN (SELECT am.locid, am.pricetype "+
" FROM supermag.smauctionatoms am "+
"WHERE am.aucid = d.id AND am.doctype = d.doctype) "+
") t "+
"ORDER BY ma_id, article",
Report.GetParameterValue("P_LOC"),
Report.GetParameterValue("P_PRICE_TYPE")
);
Я не знаток, конечно, но по-моему проще переписать...
Тут куда не плюнь, попадешь в supermag.smauctionatoms,t.ma_id и прочую фигню связанную с маркетинговыми акциями. А вообще Вы уверены что стоит отвязывать? Если вы используете акт переоценки просто, то воспользуйтесь МА вместо него. Все равно из истории цен берет инфу
ценник, а эффект тот же.