比如:
车牌
ABCDE
12345
ABCDE
54321
12345
ABCDE
如上加入数据行中有5条记录,车牌号的记录如上,我现在希望得到如下结果
车牌 个数
ABCDE 3
12345 2
54321 1
请问该如何写sql语句呢?(最好是用1条语句搞定)
31 个解决方案
#1
每天回帖即可获得10分可用分
#2
select 车牌,Count(*) from 表 group by 车牌
#3
每天回帖即可获得10分可用分
#4
#2正确
#5
select count(*), 车牌 from table1 group by 车牌 order by count(*) desc
#6
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
#7
2楼正解
统计一个:
select 车牌,Count(*) from 表 where 车牌='ABCDE'
#8
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
用group by 就行了
#9
不错,收藏了
#10
大数据量别忘了查询的时候加索引。
#11
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
#12
每天回帖即可获得10分可用分
#13
每天回帖即可获得10分可用分
#14
select 车牌,Count(*) from 表 group by 车牌 having 车牌='aaaaa'
#15
如果只是查车牌的话给车牌加个索引
#16
Friendly Up!
#17
select distinct 车牌,count(车牌) from 表
#18
select 车牌,Count(*) from 表 group by 车牌
var a=from p in ***
where Group By 车牌="***"
select(count(P));
#19
二楼正解。
#20
UP
#21
select 车牌,Count(*) from 表 group by 车牌
#22
回个帖,为了10分。
#23
這個就行的 ·
#24
我也过来接点分:select 车牌,count(车牌) as 数量 from tbl group by 车牌
#25
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
#26
飘过。。学习一下
#27
走过路过,看过
#28
2l亮了
#29
谢谢大家,select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
这条sql最完美
这条sql最完美
#30
学习,飘过……
#31
谢谢你们
#1
每天回帖即可获得10分可用分
#2
select 车牌,Count(*) from 表 group by 车牌
#3
每天回帖即可获得10分可用分
#4
#2正确
#5
select count(*), 车牌 from table1 group by 车牌 order by count(*) desc
#6
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
#7
2楼正解
统计一个:
select 车牌,Count(*) from 表 where 车牌='ABCDE'
#8
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
用group by 就行了
#9
不错,收藏了
#10
大数据量别忘了查询的时候加索引。
#11
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
#12
每天回帖即可获得10分可用分
#13
每天回帖即可获得10分可用分
#14
select 车牌,Count(*) from 表 group by 车牌 having 车牌='aaaaa'
#15
如果只是查车牌的话给车牌加个索引
#16
Friendly Up!
#17
select distinct 车牌,count(车牌) from 表
#18
select 车牌,Count(*) from 表 group by 车牌
var a=from p in ***
where Group By 车牌="***"
select(count(P));
#19
二楼正解。
#20
UP
#21
select 车牌,Count(*) from 表 group by 车牌
#22
回个帖,为了10分。
#23
這個就行的 ·
#24
我也过来接点分:select 车牌,count(车牌) as 数量 from tbl group by 车牌
#25
select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
#26
飘过。。学习一下
#27
走过路过,看过
#28
2l亮了
#29
谢谢大家,select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
这条sql最完美
这条sql最完美
#30
学习,飘过……
#31
谢谢你们