1.统计本月、上月数据

        
// 上月
long lastMonth = new DeviceRepairs() .selectCount( Wrappers.lambdaQuery(DeviceRepairs.class) .apply( " PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( create_time, '%Y%m' ) ) =1 ") .last(" limit 1"));
// 本月       
long currentMonth= new FarmCrop() .selectCount( Wrappers.lambdaQuery(FarmCrop.class) .apply( " DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m' ) ") .last(" limit 1"));

2.聚合函数

                        DeviceWeatherData maxSpeed =
                                new DeviceWeatherData()
                                        .selectOne(
                                                Wrappers.query(new DeviceWeatherData())
                                                        .select(" max(windSpeed) as windSpeed ")
                                                        .lambda()
                                                        .eq(
                                                                DeviceWeatherData::getDeviceId,
                                                                deviceId)
                                                        .apply(
                                                                " to_days(create_time) = to_days(now()) "));