table
number wc
12 18
12 17
14 19
15 18
15 9
select number,wc,count(number) from table where number='12'是不对的。
select number,wc,count(number) from table where number='12'group by number是不对的。
可是我要实现
把number 为12都找出来,还要算出总和来,此例中总和为:2
我要得到
number wc 计数
12 18 2
12 17 2
计数就是符合条件的有多少个?
number wc
12 18
12 17
14 19
15 18
15 9
select number,wc,count(number) from table where number='12'是不对的。
select number,wc,count(number) from table where number='12'group by number是不对的。
可是我要实现
把number 为12都找出来,还要算出总和来,此例中总和为:2
我要得到
number wc 计数
12 18 2
12 17 2
计数就是符合条件的有多少个?
解决方案 »
- mysql查询结果返回XML格式 类似for xml
- mysql中怎么知道当前是用哪个数据库?
- 【百度分享】MySQL 5.1分区技术初探(一)
- java如何导出blob字段的内容,并导入
- 我在重新编译mysql 4-1 提供的例子(mytest.c),总在#include<mysql.h>,#include<mysql_com.h>出错,为什么?
- MySql运行一段时间就会关闭
- 周末MySQL挂了,这个是日志,请大神看看
- 触发器中如何先判断结果集为空再进行插入操作
- mysql group by where 性能调优
- MySQL 始终连不上 本地也一样 Navicat 连接完全没问题,但是一旦AS JAVA 代码连接就出现如下错误 麻烦大神解救啊!!!!!!!!!!!!!!!
- 高分求多表查询!
- 跨库查询
from (
select num,wc
from tb
where wc=12
)A,(select count(*) c from tb where wc=12)B
SELECT number,wc,COUNT(number) AS sums FROM table WHERE number='12' GROUP BY number,wcnumber wc sums
12 18 1
12 17 1
from table a,(select count(*) 计数 cnt from table where number='12') b
where a.number='12'
mysql又没有sum over() 分析函数
基本上要2个语句啦
number wc sums
12 18 2
12 17 1
sums值会变的,你确定sql没写错?