First, use MySQL to query the 60-day data from now
SelectCount (*), B1.record_datefromnk_house_use_record as B1, (Selecta.theme_id,a.theme_name,b.house_id,b.house_ Namefromnk_house_theme as a,nk_house as bwherea.theme_id = ' 08a649fd-b83e-41b5-b88b-99598d4c93fe ' and a.theme_id = B.theme_idand a.state = ' 1 ' and b.state = ' 1 ') as a1wherea1.house_id = B1.house_idand time1 = ' 0 ' and record_date >= CURD ATE () # ' 2016-06-05 ' and Record_date < Date_sub (Curdate (), INTERVAL-60 day) GROUP byb1.record_date
Second, porting to Mabits.
<SelectID= "Queryfreehousecalender"Resulttype= "Com.cn.front.entity.detail.FreeHouseCalender"ParameterType= "Com.cn.front.entity.input.QueryFreeHouse">SELECT Count (*) as NUM, b1.record_date from Nk_house_use_record as B1, (SELECT a.theme_id, A.theme_name, b.h ouse_id, b.house_name from Nk_house_theme as a, NK _house as b WHERE a.theme_id = #{themeid} and a.theme_id = b.theme_id and a.state = ' 1 ' and b.state = ' 1 ') as A1 WHERE a1.house_id = B1 . house_id<ifTest= "TimeKey = = ' 1 '">and time1 = ' 0 '</if> <ifTest= "TimeKey = = ' 2 '">and time2 = ' 0 '</if> <ifTest= "TimeKey = = ' 3 '">and Time3 = ' 0 '</if> <ifTest= "TimeKey = = ' 4 '">and time4 = ' 0 ' and time5= ' 0 '</if> <ifTest= "StartDate! = null">and Record_date>= #{startdate}</if> <ifTest= "EndDate! = null">and Record_date<= #{enddate}</if> <ifTest= "StartDate = = null">and Date (record_date)>= Curdate ()</if> <ifTest= "EndDate = = null">and Date (record_date)<Date_sub (Curdate (), INTERVAL-60 Day)</if>GROUP by B1.record_date</Select>
XML special Symbol escape notation
< <
> >
<> <>
& &
' ‘
" "
MySQL vs. Mabits size comparison, date comparison example