mybatis-plus拼接sql报错
复制报错sql语句到navicat,字段之间缺少空格,补上就可以了
聚合sql 根据时间
json接收@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")@DateTimeFormat(pattern = "yyyy-MM-dd")private Date startTime;@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")@DateTimeFormat(pattern = "yyyy-MM-dd")private Date endTime;private Integer pageNo;private Integer pageSize;查询语句
xxxMapper.query(startTime , endTime , (pageNo - 1) * pageSize, pageSize)
@Select(" select count(*) as total , " +"sum(collection_type = 0 ) as c0, " +"sum(collection_type = 1 ) as c1, " +"sum(collection_type = 2 ) as c2, " +"sum(collection_type = 3 ) as c3, " +"sum(collection_type = 4 ) as c4, " +"sum(collection_type = 5 ) as c5, " +"sum(collection_type = 6 ) as c6, " +"sum(collection_type = 7 ) as c7, " +"sum(collection_type = 8 ) as c8, " +"sum(collection_type = 9 ) as c9, " +"sum(collection_type = 10 ) as c10, " +"DATE_FORMAT( create_time, '%Y-%m-%d' ) as date " +"from table " +"where create_time BETWEEN #{startTime} and #{endTime} " +"group by DATE_FORMAT( create_time, '%Y-%m-%d' ) " +"order by DATE_FORMAT( create_time, '%Y-%m-%d' ) desc " +"limit #{start},#{end} ")List<TableVo> query(Date startTime, Date endTime, Integer start, Integer end);
结果