| | 135 | select distinct c.category_id, c.category_name, |
| | 136 | case when tabela.naracan_proizvod >= 1 then tabela.naracan_proizvod else 0 end as naracani_proizvodi |
| | 137 | from category as c |
| | 138 | join product as p on p.category_id=c2.category_id |
| | 139 | join product_in_store as pis on p.product_id=pis.product_id |
| | 140 | join orders as o on o.product_in_store_id=pis.product_in_store_id |
| | 141 | join( |
| | 142 | select distinct c2.category_id, c2.category_name, count(o.product_in_store_id) as naracan_proizvod |
| | 143 | from category as c2 |
| | 144 | join product as p on p.category_id=c2.category_id |
| | 145 | join product_in_store as pis on p.product_id=pis.product_id |
| | 146 | join orders as o on o.product_in_store_id=pis.product_in_store_id |
| | 147 | group by 1, 2 |
| | 148 | ) as tabela on c.category_id=tabela.category_id |
| | 149 | }}} |
| | 150 | |