用分组,组内计数就可以了,意思就是根据字段a的取值进行分组,相同的为一组,在用count进行组内计数。select a,count(*) from a group by a 扩展资料:sql统计重复数据 1、生成表 create table test1 col1 char(2), col2 int go 2、插入数据 insert into test1 values('aa',1000);inse...
没怎么看懂,看你是不是要这样的效果吧, 建立表 create table test(b1 varchar(10)) 插入数据 insert into dbo.test (b1) select 'a01' union all select 'b01' union all select 'a01' union all select 'b01' select*from test 查询 select b1...
sql语句是否有漏洞是和程序结合起来说的,比如程序传一个参数进来之前没有过滤掉危险字符,就会产生漏洞,所以一般可以先过滤也可以使用存储过程. 比如登陆的sql语句为:select*from user where username='参数1' and password='参数2' 如果我参数1与参数2都为:'tt' or 1=1 那么sql语句就成了 select*from ...