Croatica ADMIN: Greska pri upitu bazi:
select case when substr(datum,6,2)='08' then 1 when substr(datum,6,2)='07' then 2 when substr(datum,6,2)='09' then 3 when substr(datum,6,2)='06' then 4 end mj, count(*) br from ( select * from ( select d.datum, obj_id, 1 kalstatus_id from kal_dani d where 1=1 and d.datum >= '2014-06-01' and d.datum <= '2014-09-30' union select d.datum, d.obj_id, d.kalstatus_id from kal_raspolozivost d where 1=1 and d.obj_id='' and d.datum >= '2014-06-01' and d.datum <= '2014-09-30' ) y group by y.datum, y.obj_id having max(y.kalstatus_id)=1 ) a where to_days(now()) between to_days('2014-03-01') and to_days('2014-09-30') and substr(datum,6,2) >= date_format(now(),'%m') group by substring(datum,1,7), case when substr(datum,6,2)='08' then 1 when substr(datum,6,2)='07' then 2 when substr(datum,6,2)='09' then 3 when substr(datum,6,2)='06' then 4 end having count(*)<=14 order by case when substr(datum,6,2)='08' then 1 when substr(datum,6,2)='07' then 2 when substr(datum,6,2)='09' then 3 when substr(datum,6,2)='06' then 4 end limit 0,1