select phone,count(order_id) as c from table_record
group by phone
order by c desc

SELECT
CASE
WHEN (age >= 10 AND age <= 20) THEN
'10-20'
WHEN (age >= 21 AND age <= 30) THEN
'21-30'
ELSE
'30-'
END 'eag_layer',
count(*) emps
FROM
address_book
GROUP BY
CASE
WHEN (age >= 10 AND age <= 20) THEN
'10-20'
WHEN (age >= 21 AND age <= 30) THEN
'21-30'
ELSE
'30-'
END
ORDER BY
1;

SELECT '10-20' 年龄段, COUNT(*) 人数
FROM [Table]
WHERE [年龄] BETWEEN 10 AND 20
UNION ALL
SELECT '21-30' 年龄段, COUNT(*) 人数
FROM [Table]
WHERE [年龄] BETWEEN 21 AND 30
UNION ALL
SELECT '31' 年龄段, COUNT(*) 人数
FROM [Table]
WHERE [年龄] > 30

select case when [年龄] BETWEEN 10 AND 20 then '10-20'
when [年龄] BETWEEN 20 AND 30 then '20-30'
when [年龄] > 30 then '30以上' end as '年龄段',
count(*) as '人数' FROM [Table]

先将年龄除10取整

select floor(年龄/10) as age from 表
1
再根据年龄整数分组统计

select age ,count(age) from
(
select floor(年龄/10) as age from 表
)
group by age

这样基本效果就出来了,达到楼主的要求就要加如函数计算了

sql语法

select convert(varchar,age*10)+'--'+convert(varchar,(age+1)*10) ,count(age) from
(
select floor(年龄/10) as age from 表
)
group by age

https://stackoverflow.com/questions/10423781/sql-data-range-min-max-category的更多相关文章

  1. https://stackoverflow.com/questions/51751426/failed-to-run-the-da-platform-trial-vm

    https://stackoverflow.com/questions/51751426/failed-to-run-the-da-platform-trial-vm {  "annotat ...

  2. https://stackoverflow.com/questions/40949967/running-storm-from-intellij-nimbus-error

    https://stackoverflow.com/questions/40949967/running-storm-from-intellij-nimbus-error 0down votefavo ...

  3. https://stackoverflow.com/questions/16130292/java-lang-outofmemoryerror-permgen-space-java-reflection

    https://stackoverflow.com/questions/16130292/java-lang-outofmemoryerror-permgen-space-java-reflectio ...

  4. 国外的非常好的开发提问回答的网站https://stackoverflow.com/questions

    https://stackoverflow.com/questions 可以进行搜索,在页面顶部,有搜索输入框

  5. https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth

    https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth p.p ...

  6. LINQ to SQL Count/Sum/Min/Max/Avg Join

    public class Linq { MXSICEDataContext Db = new MXSICEDataContext(); // LINQ to SQL // Count/Sum/Min/ ...

  7. JS中Float类型加减乘除 修复 JQ 操作 radio、checkbox 、select LINQ to SQL:Where、Select/Distinct LINQ to SQL Count/Sum/Min/Max/Avg Join

    JS中Float类型加减乘除 修复   MXS&Vincene  ─╄OvЁ  &0000027─╄OvЁ  MXS&Vincene MXS&Vincene  ─╄Ov ...

  8. IIS Express 域认证问题(https://stackoverflow.com/questions/4762538/iis-express-windows-authentication)

    option-1: edit \My Documents\IISExpress\config\applicationhost.config file and enable windowsAuthent ...

  9. del|append()|insert()|pop()|remove()|sort()|sorted|reverse()|len()|range()|min()|max()|sum()|[:]|区分两种列表复制|

    fruit = ['apple','banana','peach'] print fruit[0],fruit[-1] fruit_1 =[] fruit_1.append('orange') pri ...

随机推荐

  1. Linux 互斥锁

    互斥的概念 在多线程编程中,引入了对象互斥锁的概念,来保证共享数据操作的完整性. 每个对象都对应于一个可称为" 互斥锁" 的标记,这个标记用来保证在任一时刻, 只能有一个线程访问该 ...

  2. SNF软件开发机器人平台2018-发展升级履历-零编程时代

    一.SNF软件开发机器人产品白皮书 二.SNF开发机器人教程:链接:https://pan.baidu.com/s/1Qpomg11c_1b1NKY5P7e4Bw 密码:jwc3 三.SNF软件开发机 ...

  3. Android中的指纹识别

    转载请注明出处:http://blog.csdn.net/wl9739/article/details/52444671 评论中非常多朋友反映,依据我给出的方案,拿不到指纹信息这个问题,在这里统一说明 ...

  4. B2B相关编码说明

    B2B Cross reference Pre-Ordering enliteB2B RosettaNet EDIFACT ANSI X12 OAGIS iDOC Price Catalogue X ...

  5. Gin框架使用详解

    1.什么是Gin Gin是go编写的一个web应用框架. 2.Gin安装 go get github.com/gin-gonic/gin 3.Gin使用示例 package main import ( ...

  6. vue 的rem 配置和flexible.js的应用

    1.环境的配置: C:\Windows\System32\drivers\etc 2.多行注释: 光标放在函数中间,连按两次:“Ctrl+Alt+D”,就会出现以下的内容 3.总结使用过程:vue移动 ...

  7. spring源码:Aware接口

    一.spring容器中的aware接口介绍 Spring中提供了各种Aware接口,比较常见的如BeanFactoryAware,BeanNameAware,ApplicationContextAwa ...

  8. win10下安装基于caffe的 Faster-Rcnn

    安装教程   本篇博客将会教会你在Windows下配置py-faster-rcnn,请细心仔细阅读.说白了,Windows下配置这些东西就是一个坑. 安装配置Anaconda   由于py-faste ...

  9. centos7 RTMP直播服务器搭建

    首先需要下载 nginx-1.8.1 : http://nginx.org/download/nginx-1.8.1.tar.gz nginx-rtmp-module : https://github ...

  10. hibernate 映射一对多

    参考笔记: https://www.cnblogs.com/biehongli/p/6561690.html