0

我有3张表,必须找出每个申请人申请的申请人编号,姓名和职位总数。

CREATE TABLE    APP (
appNum      varchar2(10)    not null,
appName     varchar2(70),
constraint applicant_Pkey primary key (appNum)
);

CREATE TABLE    POS (
posNum          varchar2(10)    not null,
posStartOfferDt     date        not null,
constraint pos_Pkey primary key (posNum, posStartOfferDt)
);



CREATE TABLE    APPLICATION (
appcnPosNum     varchar2(10)    not null,
appcnPosStOffrDt    date        not null,
appcnAppNum     varchar2(10)    not null,
appcnDt         date,
constraint application_Pkey primary key (appcnPosNum, appcnPosStOffrDt, appcnAppNum),
constraint application_Fkey1 foreign key (appcnPosNum, appcnPosStOffrDt) references     POSITION(posNum, posStartOfferDt),
constraint application_Fkey2 foreign key (appcnAppNum) references APPLICANT(appNum)
);

我尝试过使用子查询、自然连接,但都不适用于我。

4

1 回答 1

1
SELECT   appNum, appName, COUNT(*)
FROM     applicant
JOIN     application ON applicant.appNum = application.appcnAppNum
GROUP BY appNum, appName
于 2013-11-01T15:26:11.070 回答