信息:的
TABLE =赠品
FORM 1 = id
FORM 2 =用户名
FORM 3 = userid
FORM 4 =愿望
结束信息
我正在尝试通过重复的用户名和用户ID
进行过滤注意:人们输入用户ID和用户名(用于赠品)
有人可以给我发一些代码吗?
答案 0 :(得分:0)
试试这个:
SELECT `username`,`userid` FROM `giveaway` group by `username` HAVING COUNT(`username`) > 1 UNION SELECT `username`,`userid` FROM `giveaway` group by `userid` HAVING COUNT(`userid`) > 1
答案 1 :(得分:0)
drop table test;
/
create table test
(
id number,
username varchar2(20),
userid number,
wish varchar2(40)
);
/
insert into test
values(1,'A',1,'ZXX');
/
insert into test
values(1,'A',1,'YYY');
/
insert into test
values(1,'B',2,'ZXX');
/
SELECT * FROM
(
SELECT ID ,USERNAME,USERID,COUNT(*) OVER (PARTITION BY USERNAME,USERID) AS CNT
FROM TEST
)
WHERE CNT <2
这将为您提供唯一值