我想获得表中最大重复的整数我尝试了很多方法,但无法使其工作。我在寻找的结果是:计数重复的数据
"james";"108"
由于这108当我Concat的两个领域LOCA + locb重复了两次,但别人没有我尝试用以下样本表结构和查询sqlfiddle链接我想... sqlfiddle link
查询我想的是:
select * from (
select name,CONCAT(loca,locb),loca,locb
, row_number() over (partition by CONCAT(loca,locb) order by CONCAT(loca,locb)) as att
from Table1
) tt
where att=1
please click这里,所以你可以看到完整的示例表和查询我试过了。
Edite:添加完整的表结构及数据:
CREATE TABLE Table1
(name varchar(50),loca int,locb int)
;
insert into Table1 values ('james',100,2);
insert into Table1 values ('james',100,3);
insert into Table1 values ('james',10,8);
insert into Table1 values ('james',10,8);
insert into Table1 values ('james',10,7);
insert into Table1 values ('james',10,6);
insert into Table1 values ('james',0,7);
insert into Table1 values ('james',10,0);
insert into Table1 values ('james',10);
insert into Table1 values ('james',10);
什么我要找的是作为价值被重复两次在整个数据获取(詹姆斯,108),还有的repetion (james,10)但是loca的值为null,所以Zero值和Null值只能被视为在两个(loca,locb)中都有值。
排序由你的分区上并没有真正意义相同的值。请将示例数据添加到您的问题 - SQLFiddle不是真的可靠,目前不适合我。 –
你好,谢谢我更新了样本数据和数据.. – hi4ppl
'CONCAT(loca,locb)'没有意义。 'concat()'是连接字符串(文本)的值,而不是数字 –