[Koha] Variables in reports

Cab Vinton bibliwho at gmail.com
Thu Jun 7 02:41:35 NZST 2018


Hi, All --

We have a report with the following WHERE clause:

  WHERE b.biblionumber IN (SELECT biblionumber FROM items WHERE
DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= dateaccessioned AND
homebranch='KIMBALL')
  AND b.biblionumber IN (SELECT biblionumber FROM items WHERE
DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= dateaccessioned AND
homebranch='PLAISTOW')
  AND b.biblionumber IN (SELECT biblionumber FROM items WHERE
DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= dateaccessioned AND
homebranch='SANDOWN')

Is there a way to declare & assign variables within a standard report?

I'm familiar w/ the section in the Reports wiki on runtime parameters
& variables (https://wiki.koha-community.org/wiki/SQL_Reports_Library#Runtime_Parameters).
I've also played around w/ SET statements. But no luck finding a way
to avoid repeating the date calculation three times without getting
errors.

As an aside, here's another approach to finding items owned by all 3 branches:

  WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= i.dateaccessioned AND
i.homebranch IN ('kimball','plaistow','sandown')
  GROUP BY biblionumber
  HAVING count(DISTINCT homebranch) = 3

Thanks in advance for any guidance.

All best,

Cab Vinton
Plaistow Public Library
Plaistow, NH


More information about the Koha mailing list