select suggestions.biblionumber,
ExtractValue(marcxml,'//datafield[@tag="200"]/subfield[@code="a"]') title,
ifnull(ExtractValue(marcxml,'//datafield[@tag="200"]/subfield[@code="e"]'),"") subtitle,
ifnull(ExtractValue(marcxml,'//datafield[@tag="200"]/subfield[@code="f"]'),"") author,
score from biblioitems
join (
	select items.biblionumber, count(distinct old_issues.borrowernumber) score from old_issues,items
	where
	items.itemnumber=old_issues.itemnumber and
	old_issues.issuedate > DATE_SUB(NOW(),INTERVAL 1 YEAR) and
	borrowernumber in (
		select distinct borrowernumber from items,old_issues where items.itemnumber=old_issues.itemnumber and items.biblionumber=323102 and borrowernumber is not null
	)
    and items.biblionumber <> 323102
    group by items.biblionumber
    order by score desc,rand()
    limit 10
    ) suggestions
on biblioitems.biblionumber=suggestions.biblionumber;
