原查询
select sum(case when age<=16 then 1 else 0 end ) age1,
sum(case when age>16 and age<=25 then 1 else 0 end ) age2,
sum(case when age>25 and age<=35 then 1 else 0 end ) age3,
sum(case when age>35 and age<=45 then 1 else 0 end ) age4,
sum(case when age>45 and age<=55 then 1 else 0 end ) age5,
sum(case when age>55 and age<=65 then 1 else 0 end ) age6,
sum(case when age>65 and age<=75 then 1 else 0 end ) age7,
sum(case when age>75 then 1 else 0 end ) age8,
count(id) other
from snap_face

经检查发现xml格式 <=号无法正确识别
改过之后的查询
select sum(case when age <=16 then 1 else 0 end ) age1,
sum(case when age>16 and age <=25 then 1 else 0 end ) age2,
sum(case when age>25 and age <=35 then 1 else 0 end ) age3,
sum(case when age>35 and age <=45 then 1 else 0 end ) age4,
sum(case when age>45 and age <=55 then 1 else 0 end ) age5,
sum(case when age>55 and age <=65 then 1 else 0 end ) age6,
sum(case when age>65 and age <=75 then 1 else 0 end ) age7,
sum(case when age>75 then 1 else 0 end ) age8,
count(id) other
from snap_face

  • 附:XML转义字符

<< 小于号;

>> 大于号;

& & 和 ;

' ‘’单引号;

" “” 双引号;

关于mybatis条件查询 报错:元素内容必须由格式正确的字符数据或标记组成的更多相关文章

  1. MyBatis异常:元素内容必须由格式正确的字符数据或标记组成

    今天在写接口查询SQL时,报了一个异常,如下: Cause: org.apache.ibatis.builder.BuilderException: Error creating document i ...

  2. Mybatis 元素内容必须由格式正确的字符数据或标记组成

    一个web应用,框架为SpringMVC Spring Mybatis ,昨天写了一下午的代码,因为逻辑较大,期间也没测,打算写完这个功能点在进行测试,谁知道写完的时候,tomcat根本启动不起来了, ...

  3. mybatis异常 :元素内容必须由格式正确的字符数据或标记组成。

    今天同事写一个查询接口的时候,出错:元素内容必须由格式正确的字符数据或标记组成. 错误原因:mybatis查询的时候,需要用到运算符 小于号:< 和  大于号: >,在mybatis配置文 ...

  4. 关于MyBatis一些小错误,元素内容必须由格式正确的字符数据或标记组成.

    今天在Mapper.xml文件写查询语句报了个奇怪的错误 Caused by: org.apache.ibatis.builder.BuilderException: Error creating d ...

  5. Cause: org.xml.sax.SAXParseException; lineNumber: 45; columnNumber: 62; 元素内容必须由格式正确的字符数据或标记组成。

    三月 09, 2018 12:13:39 下午 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending ...

  6. org.xml.sax.SAXParseException: 元素内容必须由格式正确的字符数据或标记组成,的错误问题

    当时在mapper其中的一个语句是case when ISNULL(b.c_truename) || LENGTH(TRIM(b.c_truename)) < 1 then b.c_ch_nam ...

  7. 【mybatis】【mysql】mybatis查询mysql,group by分组查询报错:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column

    mybatis查询mysql,group by分组查询报错:Expression #1 of SELECT list is not in GROUP BY clause and contains no ...

  8. 【Mybatis】mybatis查询报错org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'areaName' in 'class java.lang.String'

    mybatis查询报错: Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pro ...

  9. myBatis查询报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

    myBatis查询报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL se ...

随机推荐

  1. framework7 入门(基础布局)

    个人认为framework7是个很好的移动端框架,自带路由.下拉刷新.无限加载.时间线.各种dialog.环形图等,基本能满足大部分app的需求,可以和vue,webpack 等各种搭配. 这里讲一下 ...

  2. Mesos源码分析(12): Mesos-Slave接收到RunTask消息

    在前文Mesos源码分析(8): Mesos-Slave的初始化中,Mesos-Slave接收到RunTaskMessage消息,会调用Slave::runTask.   void Slave::ru ...

  3. 【RL-TCPnet网络教程】第13章 RL-TCPnet之TCP服务器

    第13章      RL-TCPnet之TCP服务器 本章节为大家讲解RL-TCPnet的TCP服务器实现,学习本章节前,务必要优先学习第12章TCP传输控制协议基础知识.有了这些基础知识之后,再搞本 ...

  4. Javascript高级编程学习笔记(57)—— 事件(1)事件流

    事件 JS与HTML的交互是通过事件实现的 而事件指的就是:文档或浏览器窗口特定的交互瞬间 可以通过侦听器来预定事件,以便在事件发生时执行相应的代码 这种模式也是设计模式中的观察者模式 事件流 有了事 ...

  5. [Swift]LeetCode17. 电话号码的字母组合 | Letter Combinations of a Phone Number

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...

  6. mybatis 详解------动态SQL

    mybatis 详解------动态SQL   目录 1.动态SQL:if 语句 2.动态SQL:if+where 语句 3.动态SQL:if+set 语句 4.动态SQL:choose(when,o ...

  7. Jedis与Luttuce区别

    如果你在网上搜索Redis 的Java客户端,你会发现,大多数文献介绍的都是 Jedis. 不可否认,Jedis是一个优秀的基于Java语言的Redis客户端. 但是,其不足也很明显:Jedis在实现 ...

  8. ASP.Net Core项目在Mac上使用Entity Framework Core 2.0进行迁移可能会遇到的一个问题.

    在ASP.Net Core 2.0的项目里, 我使用Entity Framework Core 2.0 作为ORM. 有人习惯把数据库的连接字符串写在appSettings.json里面, 有的习惯写 ...

  9. 取代 FlashP2P,H5P2P 将成为 WebP2P 主流

    5 月 19.20 日,行业精英齐聚的 WebRTCon 2018 在上海举办.又拍云 PrismCDN 项目负责人凌建发在大会做了<又拍云低延时的 WebP2P 直播实践>的精彩分享. ...

  10. 【快速入门ORM框架之Dapper】大牛勿进系列

    前言:dapper是什么?Dapper是.NET下一个micro的ORM,它和Entity Framework或Nhibnate不同,属于轻量级的,并且是半自动的.也就是说实体类都要自己写.它没有复杂 ...