create temporary table callnumbers ( callnumber varchar(255) primary key, count int not null ) ;
insert into callnumbers select itemcallnumber,count(itemcallnumber) from items where itemcallnumber like 'CA%' group by itemcallnumber ;

-- Dodijeljene signature u skupini CA00
select count(biblio.biblionumber) as primjeraka, 
	callnumbers.count as signatura, 
	items.itemcallnumber as novasignatura,
	biblio.author as autor,
	biblio.title as naslov,
	biblioitems.publicationyear as godina,
	biblioitems.volume as svezak,
	items.biblionumber,
	biblioitems.number as starasignatura,
	items.timestamp 
from items 
left join biblioitems on (items.biblioitemnumber=biblioitems.biblioitemnumber) 
left join biblio on (biblioitems.biblionumber=biblio.biblionumber) 
LEFT JOIN callnumbers on (items.itemcallnumber=callnumbers.callnumber)
where items.itemcallnumber is not null and items.itemcallnumber like 'CA00%' 
group by biblio.biblionumber 
order by items.itemcallnumber ;
