| 89 | |
| 90 | === Извештај за категориите со најмногу продадаени артикли=== |
| 91 | |
| 92 | {{{#!sql |
| 93 | select c.categoryname, a.articlename, coalesce(sum(i.quantity),0) as vkol from articles a |
| 94 | left join article_belongs_to_category abtc on abtc.articleid=a.articleid |
| 95 | left join categories c on c.categoryid=abtc.categoryid |
| 96 | left join invoicedarticles i on i.articleid=a.articleid |
| 97 | group by c.categoryid, a.articleid |
| 98 | having coalesce(sum(i.quantity), 0)=( |
| 99 | select max(vkol) from |
| 100 | ( |
| 101 | select coalesce(sum(i.quantity),0) as vkol from articles a |
| 102 | left join article_belongs_to_category abtc on abtc.articleid=a.articleid |
| 103 | left join categories c on c.categoryid=abtc.categoryid |
| 104 | left join invoicedarticles i on i.articleid=a.articleid |
| 105 | group by c.categoryid, a.articleid |
| 106 | ) q1 |
| 107 | ) |
| 108 | |
| 109 | |
| 110 | }}} |