原查询
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. 循环结构for

    教程:高能:语句结构都是由关键字开头,用冒号结束! 一:语句结构 for <variable> in <sequence>:    <statements>else ...

  2. JS加密对应的c#解码

      escape不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z encodeURI不编码字符有82个:!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,? ...

  3. B4 and After: Managing Hierarchy, Partitioning, and Asymmetry for Availability and Scale in Google’s Sofware-Defined WAN

    B4及之后:为谷歌软件定义WAN的可用性和扩展管理层次化.划分和不对称 本文为SIGCOMM 2018会议论文,由谷歌提供. 笔者翻译了该论文.由于时间仓促,且笔者英文能力有限,错误之处在所难免:欢迎 ...

  4. VSCode调试Flutter的问题解决

    错误:Target of URI doesn't exist: package:fultter/material.dart 原因:flutter版本不匹配.flutter升级到了最新版本,而项目引用的 ...

  5. 基础:新建个maven项目

    首先在电脑上配置好Maven环境 第一步:在Eclipse中选择创建Maven Project Next Next Finish 创建好后项目结构如下: 第二步:讲项目转为Web项目,右键项目点击pr ...

  6. 推荐几个牛逼的 IDEA 插件,还带动图!

    阅读本文大概需要 2.3 分钟. 作者:纪莫, cnblogs.com/jimoer 这里只是推荐一下好用的插件,具体的使用方法不一一详细介绍. JRebel for IntelliJ 一款热部署插件 ...

  7. [Swift]LeetCode276. 粉刷栅栏 $ Paint Fence

    There is a fence with n posts, each post can be painted with one of the k colors. You have to paint ...

  8. [Swift]LeetCode628. 三个数的最大乘积 | Maximum Product of Three Numbers

    Given an integer array, find three numbers whose product is maximum and output the maximum product. ...

  9. 优化之Sequence Generator组件

    优化Sequence Generator组件,需创建一个可重用的序列生成器,并同时在多个Mappings中使用它 关于Number of Cached Values Sequence Generato ...

  10. 聊聊Python的time模块

    time模块 time模块是很多人最早接触到的模块,像time.sleep(x)好像随处可见,但是time模块里面的其他方法呢?下面一起看一下time模块. 在Python中一般用这3种方式表示时间: ...