求助一条SQL
考虑所以投票记录,12个月里哪个月得到最多的投票,写出这些月份和投票的数量提示(Hint: the Oracle to_char() function can return the month for a given date.
For example, to_char(sysdate, 'MON') will return APR, assuming the current date is
12/04/2010.)
MovieInfo (mvID, title, rating, year, length, studio)
Director(directorID, firstname, lastname)
Member(username, email, password)
Actor(actorID, firstname, lastname, gender, birthplace)
Cast(mvID*, actorID*)
Direct(mvID*, directorID*)
Genre(mvID*, genre)
Ranking(username*, mvID*, score, voteDate)
insert into ranking values ('aden373',1,5,'11/10/1998');
insert into ranking values ('aden373',3,3,'13/9/2003');
insert into ranking values ('aden373',56,2,'19/11/2004');
insert into ranking values ('adria',27,2,'8/7/2004');
insert into ranking values ('adria',122,2,'1/2/2006');
insert into ranking values ('adria',145,3,'2/11/2000');
insert into ranking values ('ashlea36',2,3,'25/11/2000');
insert into ranking values ('ashlea830',12,4,'31/10/2007');
insert into ranking values ('ashlea877',25,5,'25/6/1998');
insert into ranking values ('ashley',24,5,'7/9/1999');
insert into ranking values ('ashley',6,3,'11/4/2000');
insert into ranking values ('ashley519',22,4,'7/10/2002');
insert into ranking values ('ashley519',2,4,'7/1/2006');
insert into ranking values ('ashley519',3,5,'18/7/2000');
insert into ranking values ('brian827',11,3,'17/7/2000');
insert into ranking values ('bryce',2,5,'3/3/2003');
insert into ranking values ('bryce',3,2,'27/8/2004');
insert into ranking values ('bryony427',3,3,'20/1/2001');
insert into ranking values ('buddy',2,2,'30/5/2001');
insert into ranking values ('buddy421',55,4,'13/7/1998');
insert into ranking values ('buddy421',12,5,'26/1/1998');
insert into ranking values ('burke152',5,2,'1/10/2003');
insert into ranking values ('caden',44,3,'30/5/1999');
insert into ranking values ('caden',25,3,'13/6/2000');
insert into ranking values ('cadence',6,5,'28/9/1998');
insert into ranking values ('cadence',53,5,'20/1/2002');
insert into ranking values ('cailyn',5,3,'9/3/2007');
insert into ranking values ('camden529',21,3,'25/9/2006');
insert into ranking values ('camden529',125,5,'5/12/2005');
insert into ranking values ('camden529',225,2,'28/8/2006');
insert into ranking values ('camden529',37,2,'12/11/2007');
insert into ranking values ('camden529',56,4,'16/10/2001');
insert into ranking values ('clinton',23,2,'15/4/1999');
insert into ranking values ('colbert',23,2,'10/8/2004');
insert into ranking values ('dianna',11,3,'2/5/2001');
insert into ranking values ('dianna',99,5,'19/9/1999');
insert into ranking values ('diantha518',2,4,'13/2/2005');
insert into ranking values ('docia',2,4,'21/9/1998');
insert into ranking values ('dominic',45,2,'5/6/1999');
insert into ranking values ('dorinda',8,3,'5/2/2005');
insert into ranking values ('dorinda765',7,3,'17/4/2007');
insert into ranking values ('ethan',7,4,'23/2/2006');
insert into ranking values ('ethelyn',76,5,'8/7/1998');
insert into ranking values ('ethelyn',19,2,'26/10/2007');
insert into ranking values ('eugene566',9,4,'30/10/2001');
insert into ranking values ('eustace',5,4,'13/10/2004');
insert into ranking values ('eustace',16,5,'23/12/2006');
insert into ranking values ('eustace279',4,5,'4/2/2002');
insert into ranking values ('eustace862',84,5,'18/10/2001');
insert into ranking values ('evan',55,5,'14/12/2000');
insert into ranking values ('evan',212,5,'9/12/2001');
insert into ranking values ('evan',214,4,'9/5/2000');
insert into ranking values ('evan',223,4,'10/12/2005');
insert into ranking values ('gilbert',59,3,'18/12/2003');
insert into ranking values ('gilbert520',75,2,'1/8/2006');
insert into ranking values ('gilbert520',95,3,'24/1/2005');
insert into ranking values ('ginny',46,5,'21/1/2000');
insert into ranking values ('ginny576',54,2,'4/9/1998');
insert into ranking values ('hailey',5,4,'5/3/2004');
insert into ranking values ('hailey568',4,2,'28/9/2006');
insert into ranking values ('hall',6,3,'27/6/2003');
insert into ranking values ('hamnet',54,3,'7/8/2003');
insert into ranking values ('hamnet367',28,3,'6/6/2001');
insert into ranking values ('hamnet367',168,4,'20/4/2000');
insert into ranking values ('india',35,3,'18/5/1998');
insert into ranking values ('india542',77,2,'18/4/2001');
insert into ranking values ('india542',246,4,'16/12/2005');
insert into ranking values ('iona',96,5,'10/2/2006');
insert into ranking values ('iona92',55,4,'9/4/2002');
insert into ranking values ('irene',34,4,'27/8/2004');
insert into ranking values ('isaac',18,2,'2/5/2004');
insert into ranking values ('isebella684',25,2,'9/11/2006');
insert into ranking values ('ivory972',106,3,'31/7/2002');
insert into ranking values ('ivory972',199,3,'4/10/2000');
insert into ranking values ('jacob',72,4,'15/7/2006');
insert into ranking values ('jacob552',98,5,'8/10/2007');
insert into ranking values ('jacob552',197,5,'23/11/2007');
insert into ranking values ('jacob679',37,4,'26/6/1999');
insert into ranking values ('jacob679',150,2,'17/1/2005');
insert into ranking values ('jasper',86,5,'8/9/2004');
insert into ranking values ('jeanette',43,4,'4/1/2001');
insert into ranking values ('jeanette',217,4,'6/3/1999');
insert into ranking values ('jeanette710',23,2,'24/6/2002');
insert into ranking values ('jeanette710',218,3,'26/9/2006');
insert into ranking values ('jeanette710',219,2,'30/11/2001');
insert into ranking values ('jeanette80',123,2,'22/5/1999');
insert into ranking values ('jeanette840',156,2,'29/10/1999');
insert into ranking values ('jeanette840',203,4,'7/10/2001');
insert into ranking values ('jemima',224,4,'19/10/2006');
insert into ranking values ('jemima',229,4,'23/9/2001');
insert into ranking values ('jemima',230,5,'20/2/1998');
insert into ranking values ('jemima',245,4,'19/4/2001');
insert into ranking values ('jemima365',221,3,'23/5/2000');
insert into ranking values ('ladonna',178,2,'26/10/2006');
insert into ranking values ('ladonna',180,2,'22/2/2001');
insert into ranking values ('lainey37',202,5,'12/4/2003');
insert into ranking values ('lainey686',133,5,'23/9/2004');
insert into ranking values ('lakisha',78,5,'25/9/2003');
insert into ranking values ('pearl',237,5,'4/6/2004');
insert into ranking values ('peers',156,4,'20/7/2006');
insert into ranking values ('peggy621',74,3,'13/4/2001');
insert into ranking values ('peggy621',135,5,'29/6/2007');
insert into ranking values ('percy',89,4,'26/12/2005');
insert into ranking values ('percy101',144,2,'16/7/1998');
insert into ranking values ('percy259',196,5,'17/11/2004');
insert into ranking values ('percy559',54,3,'20/5/2000');
insert into ranking values ('percy745',79,3,'30/11/2005');
insert into ranking values ('philippa441',166,4,'2/7/1999');
drop table ranking;
drop table cast;
drop table direct;
drop table genre;
drop table MovieInfo;
drop table Actor;
drop table Director;
drop table Member;
create table MovieInfo (
mvID integer,
title varchar(80),
rating varchar(5),
year integer,
length integer,
studio varchar(80),
primary key(mvID)
);
create table Director (
directorID integer,
firstname varchar(20),
lastname varchar(20),
primary key(directorID)
);
create table Member(
username varchar(40),
email varchar(80),
password varchar(40),
primary key(username)
);
create table Actor (
actorID integer,
firstname varchar(20),
lastname varchar(20),
gender character,
birthplace varchar(20),
primary key(actorID)
);
create table cast (
mvID integer,
actorID integer,
primary key(mvID, actorID),
foreign key(mvID) references MovieInfo(mvID),
foreign key(actorID) references Actor(actorID)
);
create table direct (
mvID integer,
directorID integer,
primary key(mvID, directorID),
foreign key(mvID) references MovieInfo(mvID),
foreign key(directorID) references Director(directorID)
);
create table genre (
mvID integer,
genre varchar(20),
primary key(mvID, genre),
foreign key(mvID) references MovieInfo(mvID)
);
create table ranking (
username varchar(40),
mvID integer,
score integer,
voteDate date,
primary key(username, mvID),
foreign key(username) references Member(username),
foreign key(mvID) references MovieInfo(mvID)
);