SELECT TO_CHAR(c.ARTICLE) AS ARTICLE , TO_CHAR(c.NAME) AS SHName, TO_CHAR(p.PRICE) AS PRICE, TO_CHAR(ROUND((p.PRICE *( LE.AMOUNT *(LE.PRICEPERCENT/100))),2)) AS CALC_BLOK , TO_CHAR(ROUND((p.PRICE *( LE.AMOUNT *(LE.PRICEPERCENT/100))) / LE.AMOUNT,2)) AS CALC FROM supermag.SMCARD c LEFT JOIN SUPERMAG.SMPrices p ON P.ARTICLE = C.ARTICLE LEFT JOIN supermag.smgoods g ON G.ARTICLE = C.ARTICLE AND G.STORELOC = P.STORELOC LEFT JOIN supermag.SACardClass cl ON CL.ID = C.IDCLASS RIGHT JOIN SUPERMAG.SMComplexArticles LE ON LE.ARTICLE = c.ARTICLE WHERE CL.ID in('927','928','929','930','931') AND p.PRICETYPE = "+перм1+" AND g.STORELOC = "+перем2+"
LEFT JOIN supermag.smgoods g ON G.ARTICLE = C.ARTICLE AND G.STORELOC = P.STORELOC