-2

我有一个这样的数据库:

身份证 | 访问代码

并且代码在行中重复。我想要一个看起来像这样的选择

访问代码 | 表中有多少条目与此 AcessCode 匹配

4

3 回答 3

2

像这样:

select AccessCode, COUNT(ID) as Entires
from YourTable
group by AccessCode
于 2013-11-07T14:45:52.257 回答
0

如果你想处理空值(id)......

select 
  accesscode,count(*) as total
from 
  t
group by accesscode
order by total;

见 sqlfiddle:http ://sqlfiddle.com/#!6/79fe2/1

于 2013-11-07T14:55:53.507 回答
0
select AccessCode, count(AccessCode) from sometable group by AccessCode
于 2013-11-07T14:45:54.633 回答