sql="select 1 s, count(avail) from %s where avail!=0 %s %s"%(TBL_BOOKS,dstr,period)
# sql2="select 2 s, count(*) from (select b.author_id from %s b left join %s c on b.book_id=c.book_id where c.avail!=0 %s group by b.author_id) a1"%(TBL_BAUTHORS, TBL_BOOKS, period)
# sql3="select 3 s, count(*) from (select b.genre_id from %s b left join %s c on b.book_id=c.book_id where c.avail!=0 %s group by b.genre_id) a2"%(TBL_BGENRES, TBL_BOOKS, period)
# sql4="select 4 s, count(*) from (select b.ser_id from %s b left join %s c on b.book_id=c.book_id where c.avail!=0 %s group by b.ser_id) a3"%(TBL_BSERIES, TBL_BOOKS, period)
# sql=sql1+" union all "+sql2+" union all "+sql3+" union all "+sql4+" order by s"