
数据库查询
德忱
春雨,杏花,江南。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
根据年龄分割查询每个年龄段的人数
根据年龄分割查询每个年龄段的人数本文以两种查询方式,查询每个年龄段的人数。1.普通的when case 查询select age, count(*) as num from (SELECT case when age >= 18 and age <= 20 then '1'when age >= 21 and age <= 25 then '2'when age >= 26 and age原创 2016-07-25 11:38:52 · 5412 阅读 · 0 评论 -
按照某一列统计数据
按照某一列统计数据具体需求如下:要统计一个数据表中的数据,将某一列的每个相同的值加和,作为一个新的列。具体数据如下:id result1 22 23 14 25 36 1统计结果如下,大概意思吧。id result1 result2 result31 2原创 2016-07-26 10:10:42 · 513 阅读 · 0 评论 -
MyBatis中小于等于号的处理
在使用mybatis的过程中,由于xml文件本身的标签需要用<>来标示,因此在xml文件中书写小于号时,很容易被认为是一个标签的开始标志来处理,因此,应该讲小于号写成”<”; 例如:<if test="infromTimeEnd != null and infromTimeEnd != ''"> AND e.createTime <=CONCAT('${infromTimeEnd}'原创 2016-07-27 18:21:16 · 1808 阅读 · 0 评论 -
MySQL Limit数据不足时导致查询变慢
问题有如下一个查询: 查询SQL:select * from tb_record where ctime < 1524758400 AND AND type in (2,4,6,8) id > 131946599 order by id asc limit 1000;统计SQL:select count(*) from tb_record where ctime...原创 2018-05-17 16:13:33 · 7683 阅读 · 0 评论