SELECT cc.tree AS "Подгруппа", AVG(p.price) AS "Цена" FROM supermag.smcard c, supermag.sacardclass cc, supermag.smprices p WHERE c.idclass = cc.id AND p.article = c.article AND c.accepted = 1 GROUP BY cc.tree
' select a.id,'+ ' a.tree,'+ ' a.prtree,'+ ' nvl(p.id,0) pr_id,'+ ' a.tree ||chr(32)|| a.name as name,'+ ' a.put_n'+ ' from'+ ' (select id,'+ ' replace(tree,chr(35)) tree,'+ ' nvl(rtrim(rtrim(tree,'+''''+'.'+''''+'),'+''''+'1234567890'+''''+'),'+''''+'#'+''''+') prtree,'+ ' name,'+ ' to_number(replace((replace(tree,chr(46))),chr(35),chr(48))) put_n'+ ' from sasupplierclass) a,'+ ' sasupplierclass p'+ ' where a.prtree=p.tree'+ ' order by a.put_n';
SELECT substr(cc.tree,1,instr(cc.tree, '.',1)-1) AS "Группа", AVG(p.price) AS "Цена" FROM supermag.smcard c, supermag.sacardclass cc, supermag.smprices p WHERE c.idclass = cc.id AND p.article = c.article AND c.accepted = 1 GROUP BY substr(cc.tree,1,instr(cc.tree, '.',1)-1)
SELECT classifier.gettitlebypath (classifier.gettreeprefix (cc.tree, 0), 'SACARDCLASS') "Группа", ROUND (AVG (p.price), 2) "Цена" FROM supermag.smcard c, supermag.svaartclassif cc, supermag.smprices p WHERE c.article = cc.article AND p.article = c.article AND c.accepted = 1 GROUP BY classifier.gettreeprefix (cc.tree, 0)