0

I have 3 tables, and have to find out the applicant number, name and total number of position each applicant applied for.

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)
);

I have tried using sub query, natural join but all not working out for me.

2
  • 2
    Which sql version are you using? mySql, MSSQL/T-SQL, Oracle, etc? Commented Nov 1, 2013 at 15:25
  • SELECT a.appNum, a.appName, COUNT(ap.appcnAppNum) FROM applicant a left JOIN application ap ON a.appNum = ap.appcnAppNum GROUP BY a.appNum, a.appName Commented Nov 1, 2013 at 15:35

1 Answer 1

1
SELECT   appNum, appName, COUNT(*)
FROM     applicant
JOIN     application ON applicant.appNum = application.appcnAppNum
GROUP BY appNum, appName
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.