0% found this document useful (0 votes)
188 views

Module 5 Assignment Solution

The document contains SQL queries to retrieve information from PROGRAMMER and SOFTWARE tables. The queries include: 1) Names and salaries of highest paid programmers by language. 2) Details of programmers with the same salary. 3) Programmers who joined on the same day. 4) Programmers with the same Prof2. 5) Number of packages and place of study of the programmer who developed the cheapest package.

Uploaded by

Vishnu Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
188 views

Module 5 Assignment Solution

The document contains SQL queries to retrieve information from PROGRAMMER and SOFTWARE tables. The queries include: 1) Names and salaries of highest paid programmers by language. 2) Details of programmers with the same salary. 3) Programmers who joined on the same day. 4) Programmers with the same Prof2. 5) Number of packages and place of study of the programmer who developed the cheapest package.

Uploaded by

Vishnu Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

USE JARVIS;

/*1)Display the names of the highest paid programmers for each Language.*/

SELECT STUDENT_NAME, SALARY, PROF1 FROM


(SELECT STUDENT_NAME, SALARY, PROF1, ROW_NUMBER()
OVER (PARTITION BY PROF1 ORDER BY SALARY DESC) AS ROWNUMBER FROM PROGRAMMER) SUB
WHERE ROWNUMBER = 1;

/*2) Display the details of those who are drawing the same salary.*/
SELECT * FROM PROGRAMMER
WHERE SALARY IN (SELECT SALARY
FROM PROGRAMMER
GROUP BY SALARY
HAVING COUNT(*) > 1)
ORDER BY SALARY DESC;

/*3) Who are the programmers who joined on the same day?*/
SELECT STUDENT_NAME,DOJ FROM PROGRAMMER
WHERE DOJ IN (SELECT DOJ FROM PROGRAMMER
GROUP BY DOJ
HAVING COUNT(*) > 1)
ORDER BY DOJ;

/*4) Who are the programmers who have the same Prof2*/
SELECT STUDENT_NAME, PROF2 FROM PROGRAMMER
WHERE PROF2 IN (SELECT PROF2 FROM PROGRAMMER
GROUP BY PROF2
HAVING COUNT(*) > 1)
ORDER BY PROF2;

/*5) How many packages were developed by the person who developed the cheapest
package,
where did he/she study*/

SELECT
COUNT(SO.Student_id) AS TOTAL_PACKAGES_DEVELOPED
FROM SOFTWARE SO INNER JOIN STUDIES S ON S.Student_id = SO.Student_id
WHERE SO.STUDENT_ID IN (SELECT STUDENT_ID FROM SOFTWARE
WHERE SCOST IN (SELECT MIN(SCOST) FROM SOFTWARE));

SELECT STUDENT_ID, STUDENT_PLACE FROM STUDIES


WHERE STUDENT_ID IN (SELECT Student_id FROM SOFTWARE
WHERE SCOST IN (SELECT MIN(SCOST) FROM SOFTWARE));

You might also like