Need report help from the collection mind!
I'm trying to build a simple weeding tool for one of my libraries and seem to be missing something. I am getting results where the Total_Circ is 2 or more!! The rest looks great, the results are just not narrow enough for this case. Context may be slightly different because we are on LLEK, but I believe the problem is with the SQL at WHERE items.homebranch='LX' AND 'Total_Circ'<2 We want everything where the Total Circ is less than two, obviously! SELECT CONCAT( '<a href=\"/cgi-bin/koha/cataloguing/additem.pl?biblionumber=',biblio.biblionumber, '\">',items.barcode,'</a>' ) as 'Barcode',items.itemcallnumber,biblio.author,biblio.title,items.issues,items.renewals,(IFNULL(items.issues,0)+IFNULL(items.renewals,0)) as Total_Circ,items.datelastborrowed FROM items LEFT JOIN biblioitems on (items.biblioitemnumber=biblioitems.biblioitemnumber) LEFT JOIN biblio on (biblioitems.biblionumber=biblio.biblionumber) WHERE items.homebranch='LX' AND 'Total_Circ'<2 ORDER BY items.itemcallnumber,biblio.author,biblio.title Kathy Kathleen D. Rippel Dept. Head/Consultant--Resource Sharing and Access ; Pathfinder Central (Manager) Central Kansas Library System 1409 Williams Great Bend, KS 67530 (620-792-4865) phone (800-362-2642) toll-free, KS (620-792-5495) fax kdr@ckls.org ******************************************************************************************** I'm currently reading: Magazine of Virginia genealogy, Feb. 2008 I'm currently listening to: The passage, by Justin Cronin.
On 30 March 2011 07:49, Kathy Rippel <kdr@ckls.org> wrote:
I'm trying to build a simple weeding tool for one of my libraries and seem to be missing something. I am getting results where the Total_Circ is 2 or more!! The rest looks great, the results are just not narrow enough for this case.
Context may be slightly different because we are on LLEK, but I believe the problem is with the SQL at WHERE items.homebranch='LX' AND 'Total_Circ'<2
We want everything where the Total Circ is less than two, obviously!
Yes, the problem is by making it 'Total_Circ' you have made it a literal. So it is not a column (or alias) anymore. I would do this with a subquery So like this select CONCAT( '<a href=\"/cgi-bin/koha/cataloguing/additem.pl?biblionumber=',biblio.biblionumber, '\">',countitems.barcode,'</a>' ) AS barcode_href, itemcallnumber, author, title, issues, renewals, total_circ FROM (select (IFNULL(items.issues,0)+IFNULL(items.renewals,0)) AS total_circ,itemnumber,barcode,issues,renewals,biblioitemnumber,itemcallnumber,homebranch FROM items) AS countitems LEFT JOIN biblioitems on (countitems.biblioitemnumber=biblioitems.biblioitemnumber) LEFT JOIN biblio on (biblioitems.biblionumber=biblio.biblionumber) WHERE total_circ < 2 AND homebranch = 'LX' ORDER BY itemcallnumber,author,title Chris
participants (2)
-
Chris Cormack -
Kathy Rippel