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://*.com/questions/10423781/sql-data-range-min-max-category的更多相关文章
-
https://*.com/questions/51751426/failed-to-run-the-da-platform-trial-vm
https://*.com/questions/51751426/failed-to-run-the-da-platform-trial-vm { "annotat ...
-
https://*.com/questions/40949967/running-storm-from-intellij-nimbus-error
https://*.com/questions/40949967/running-storm-from-intellij-nimbus-error 0down votefavo ...
-
https://*.com/questions/16130292/java-lang-outofmemoryerror-permgen-space-java-reflection
https://*.com/questions/16130292/java-lang-outofmemoryerror-permgen-space-java-reflectio ...
-
国外的非常好的开发提问回答的网站https://*.com/questions
https://*.com/questions 可以进行搜索,在页面顶部,有搜索输入框
-
https://*.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth
https://*.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth p.p ...
-
LINQ to SQL Count/Sum/Min/Max/Avg Join
public class Linq { MXSICEDataContext Db = new MXSICEDataContext(); // LINQ to SQL // Count/Sum/Min/ ...
-
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 ...
-
IIS Express 域认证问题(https://*.com/questions/4762538/iis-express-windows-authentication)
option-1: edit \My Documents\IISExpress\config\applicationhost.config file and enable windowsAuthent ...
-
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 ...
随机推荐
-
thinkphp加载第三方类库
http://www.cnblogs.com/jiqing9006/p/5041389.html
-
Silverlight项目笔记5:Oracle归档模式引起的异常&;&;表格控件绑定按钮
1.Oracle归档模式产生日志文件引起数据库异常 连接数据库失败,提示监听错误,各种检查监听配置文件,删除再添加监听,无果. sqlplus下重启数据库数据库依然无果,期间碰到多个错误提示: ORA ...
-
[老老实实学WCF] 第一篇 Hello WCF
老老实实学WCF 第一篇 Hello WCF WCF(Windows Communication Foundation)是微软公司推出的面向服务技术的集大成者,涵盖继承了其之前发布的所有的分布式应用 ...
-
30个HTML5学习资源
早在几个星期前,Adobe就发布了Dreamweaver CS5 HTML5 Pack的预览版下载.众所周知,HTML5在互联网领域掀起了一场大论战,并让Adobe的日子很难熬.HTML5致力于为前端 ...
-
char *s = getpass()屏幕不回显示 ,返回输入的字符
char *s = getpass(“please input you name:”)屏幕不回显示 ,返回输入的字符
-
阐述linux IPC(五岁以下儿童):system V共享内存
[版权声明:尊重原创.转载请保留源:blog.csdn.net/shallnet 要么 .../gentleliu,文章学习交流,不用于商业用途] system V共享内存和posix ...
-
使用DataFlow表达ControlFlow的一些思考
一.控制流 从接触面向过程语言开始,使用控制流编程的概念已是司空见惯. if (condition) { // do something } else { // do something else } ...
-
SpringMVC 使用JSR-303进行校验 @Valid
注意:1 public String save(@ModelAttribute("house") @Valid House entity, BindingResult result ...
-
[转]urllib模块urlretrieve方法
直接将远程数据下载到本地 info: urllib.urlretrieve(url[, filename[, reporthook[, data]]])参数说明:url:外部或者本地urlfilena ...
-
spring web应用
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...