我需要选择gno中不止重复的所有出现次数,也就是说,我需要能够在这种情况下选择1001,我该怎么做?
create table project99
(
pno int primary key,
projtitle varchar2(30),
projarea varchar2(30),
startd date,
gno int references guide99(gno)
);
insert into project99 values(1,'E Commerce website','php','03-jan-2016',1001);
insert into project99 values(2,'Web forums','php','05-jan-2016',1001);
insert into project99 values(3,'Sudoku','C','06-jan-2016',1002);
insert into project99 values(4,'Student management System','php','04-jan-2016',1003);
insert into project99 values(5,'Antivirus','System','04-jan-2016',1004);
insert into project99 values(6,'Snake','C++','03-jan-2016',1004);
insert into project99 values(7,'Library management','php','03-jan-2016',1006);
insert into project99 values(8,'Video Sharing website','C#','03-jan-2016',1005);
insert into project99 values(9,'Search Algorithm','maths','03-may-2016',1010);
insert into project99 values(10,'Email','php','03-jan-2016',1007);
答案 0 :(得分:4)
SELECT gno
FROM project99
GROUP BY gno
HAVING COUNT(1) > 1;