Module 3 Assignement Solution
Module 3 Assignement Solution
Module 3 Assignement Solution
--2) Display the details of those who don’t know Clipper, COBOL or PASCAL.
SELECT
S.STUDENT_NAME,
P.*
FROM PROGRAMMER P INNER JOIN STUDIES S ON S.Student_id = P.P_ID
WHERE PROF1 NOT IN ('CLIPPER', 'COBOL', 'PASCAL')
AND PROF2 NOT IN ('CLIPPER', 'COBOL', 'PASCAL');
SELECT
DEV_IN,
AVG(SCOST) AS AVG_SCOST,
AVG(DCOST) AS AVG_DCOST,
(AVG(SCOST))/(SUM(SOLD)) AS AVG_PRICE_PER_COPY
FROM SOFTWARE GROUP BY DEV_IN;
--6) How many packages are developed by the most experienced programmer from BDPS.
SELECT
COUNT(SO.DEV_IN) AS TOTAL,
P.DOJ,
S.Student_place
FROM SOFTWARE SO INNER JOIN STUDIES S ON S.Student_id = SO.Student_id
INNER JOIN PROGRAMMER P ON P.P_ID = SO.Student_id
WHERE S.Student_place = 'BDPS'
GROUP BY P.DOJ, S.Student_place HAVING P.DOJ = (SELECT MAX(DOJ) FROM PROGRAMMER );
SELECT
COUNT(SO.DEV_IN) AS TOTAL_PACKAGES_DEVELOPED
FROM SOFTWARE SO INNER JOIN PROGRAMMER P ON SO.Student_id = P.P_ID
WHERE P.GENDER = 'F' AND
P.SALARY > (SELECT MAX(SALARY) FROM PROGRAMMER WHERE GENDER = 'M')
GROUP BY SO.DEV_IN;
/*8)How much does the person who developed the highest selling package
earn and what course did HE/SHE undergo.*/
SELECT * FROM PROGRAMMER;
SELECT * FROM SOFTWARE;
SELECT * FROM STUDIES;
SELECT
SO.STUDENT_ID,
S.COURSE,
P.SALARY
FROM SOFTWARE SO INNER JOIN STUDIES S ON S.Student_id = SO.Student_id
INNER JOIN PROGRAMMER P ON P.P_ID = SO.Student_id
WHERE SO.SOLD IN (SELECT MAX(SOLD) FROM SOFTWARE);
/*9)In which institute did the person who developed the costliest package study?*/
SELECT STUDENT_PLACE
FROM STUDIES S INNER JOIN SOFTWARE SO ON S.Student_id = SO.Student_id
WHERE SCOST IN (SELECT MAX(SCOST) FROM SOFTWARE);
/*10)Display the names of the programmers who have not developed any packages.*/
SELECT * FROM PROGRAMMER;
SELECT * FROM SOFTWARE;
SELECT * FROM STUDIES;
/*11) Display the details of the software that has developed in the
language which is neither the first nor the second proficiency*/
SELECT
SO.DEV_IN,
P.GENDER,
P.DOB
FROM PROGRAMMER P INNER JOIN SOFTWARE SO ON SO.Student_id = P.P_ID
WHERE (P.GENDER IN (SELECT GENDER FROM PROGRAMMER WHERE GENDER = 'M')
AND YEAR(P.DOB) < 1965)
AND (P.GENDER IN (SELECT GENDER FROM PROGRAMMER WHERE GENDER = 'F')
AND YEAR(P.DOB) > 1975);
SELECT * FROM PROGRAMMER WHERE YEAR(DOB) < 1965 AND GENDER = 'M';
/*13)Display the number of packages, No. of Copies Sold and sales value
of each programmer institute wise.*/
SELECT
S.STUDENT_PLACE,
COUNT(SO.DEV_IN) AS NO_OF_PACKAGES,
SUM(SO.SOLD) AS NO_OF_COPIES_SOLD,
SUM(SO.SCOST * SO.SOLD) AS SALES_VALUE
FROM SOFTWARE SO INNER JOIN STUDIES S ON SO.Student_id = S.Student_id
GROUP BY S.Student_place;
/*15) Who are the Female Programmers earning more than the Highest Paid male*/
SELECT * FROM STUDIES;
SELECT
S.STUDENT_NAME,
P.GENDER,
P.SALARY
FROM STUDIES S INNER JOIN PROGRAMMER P ON S.Student_id = P.P_ID
WHERE P.SALARY > (SELECT MAX(SALARY) FROM PROGRAMMER WHERE GENDER = 'M')
/*22)Who Developed the Package that has sold the least number of copies?*/
SELECT STUDENT_ID, TITLE, SOLD FROM SOFTWARE
WHERE SOLD IN (SELECT MIN(SOLD) FROM SOFTWARE);