SQL – QUERIES
I. SCHEMAS
Table 1 : STUDIES
PNAME (VARCHAR), SPLACE (VARCHAR), COURSE (VARCHAR), CCOST (NUMBER)
Table 2 : SOFTWARE
PNAME (VARCHAR), TITLE (VARCHAR), DEVIN (VARCHAR), SCOST (NUMBER), DCOST (NUMBER), SOLD (NUMBER)
Table 3 : PROGRAMMER
PNAME (VARCHAR), DOB (DATE), DOJ (DATE), SEX (CHAR), PROF1 (VARCHAR), PROF2 (VARCHAR), SAL (NUMBER)
LEGEND :
PNAME – Programmer Name, SPLACE – Study Place , CCOST – Course Cost, DEVIN – Developed in, SCOST – Software Cost, DCOST – Development Cost, PROF1 – Proficiency 1
QUERIES :
- Find out the selling cost average for packages developed in Oracle.
- Display the names, ages and experience of all programmers.
- Display the names of those who have done the PGDCA course.
- What is the highest number of copies sold by a package?
- Display the names and date of birth of all programmers born in April.
- Display the lowest course fee.
- How many programmers have done the DCA course.
- How much revenue has been earned through the sale of packages developed in C.
- Display the details of software developed by Rakesh.
- How many programmers studied at Pentafour.
- Display the details of packages whose sales crossed the 5000 mark.
- Find out the number of copies which should be sold in order to recover the development cost of each package.
- Display the details of packages for which the development cost has been recovered.
- What is the price of costliest software developed in VB?
- How many packages were developed in Oracle ?
- How many programmers studied at PRAGATHI?
- How many programmers paid 10000 to 15000 for the course?
- What is the average course fee?
- Display the details of programmers knowing C.
- How many programmers know either C or Pascal?
- How many programmers don’t know C and C++?
- How old is the oldest male programmer?
- What is the average age of female programmers?
- Calculate the experience in years for each programmer and display along with their names in descending order.
- Who are the programmers who celebrate their birthdays during the current month?
- How many female programmers are there?
- What are the languages known by the male programmers?
- What is the average salary?
- How many people draw 5000 to 7500?
- Display the details of those who don’t know C, C++ or Pascal.
- Display the costliest package developed by each programmer.
- Produce the following output for all the male programmers
Programmer
Mr. Arvind – has 15 years of experience
KEYS:
- SELECT AVG(SCOST) FROM SOFTWARE WHERE DEVIN = ORACLE;
- SELECT PNAME,TRUNC(MONTHS_BETWEEN(SYSDATE,DOB)/12) "AGE", TRUNC(MONTHS_BETWEEN(SYSDATE,DOJ)/12) "EXPERIENCE" FROM PROGRAMMER;
- SELECT PNAME FROM STUDIES WHERE COURSE = PGDCA;
- SELECT MAX(SOLD) FROM SOFTWARE;
- SELECT PNAME, DOB FROM PROGRAMMER WHERE DOB LIKE %APR%;
- SELECT MIN(CCOST) FROM STUDIES;
- SELECT COUNT(*) FROM STUDIES WHERE COURSE = DCA;
- SELECT SUM(SCOST*SOLD-DCOST) FROM SOFTWARE GROUP BY DEVIN HAVING DEVIN = C;
- SELECT * FROM SOFTWARE WHERE PNAME = RAKESH;
- SELECT * FROM STUDIES WHERE SPLACE = PENTAFOUR;
- SELECT * FROM SOFTWARE WHERE SCOST*SOLD-DCOST > 5000;
- SELECT CEIL(DCOST/SCOST) FROM SOFTWARE;
- SELECT * FROM SOFTWARE WHERE SCOST*SOLD >= DCOST;
- SELECT MAX(SCOST) FROM SOFTWARE GROUP BY DEVIN HAVING DEVIN = VB;
- SELECT COUNT(*) FROM SOFTWARE WHERE DEVIN = ORACLE;
- SELECT COUNT(*) FROM STUDIES WHERE SPLACE = PRAGATHI;
- SELECT COUNT(*) FROM STUDIES WHERE CCOST BETWEEN 10000 AND 15000;
- SELECT AVG(CCOST) FROM STUDIES;
- SELECT * FROM PROGRAMMER WHERE PROF1 = C OR PROF2 = C;
- SELECT * FROM PROGRAMMER WHERE PROF1 IN (C,PASCAL) OR PROF2 IN (C,PASCAL);
- SELECT * FROM PROGRAMMER WHERE PROF1 NOT IN (C,C++) AND PROF2 NOT IN (C,C++);
- SELECT TRUNC(MAX(MONTHS_BETWEEN(SYSDATE,DOB)/12)) FROM PROGRAMMER WHERE SEX = M;
- SELECT TRUNC(AVG(MONTHS_BETWEEN(SYSDATE,DOB)/12)) FROM PROGRAMMER WHERE SEX = F;
- SELECT PNAME, TRUNC(MONTHS_BETWEEN(SYSDATE,DOJ)/12) FROM PROGRAMMER ORDER BY PNAME DESC;
- SELECT PNAME FROM PROGRAMMER WHERE TO_CHAR(DOB,MON) = TO_CHAR(SYSDATE,MON);
- SELECT COUNT(*) FROM PROGRAMMER WHERE SEX = F;
- SELECT DISTINCT(PROF1) FROM PROGRAMMER WHERE SEX = M;
- SELECT AVG(SAL) FROM PROGRAMMER;
- SELECT COUNT(*) FROM PROGRAMMER WHERE SAL BETWEEN 5000 AND 7500;
- SELECT * FROM PROGRAMMER WHERE PROF1 NOT IN (C,C++,PASCAL) AND PROF2 NOT IN (C,C++,PASCAL);
- SELECT PNAME,TITLE,SCOST FROM SOFTWARE WHERE SCOST IN (SELECT MAX(SCOST) FROM SOFTWARE GROUP BY PNAME);
32.SELECT Mr. || PNAME || - has || TRUNC(MONTHS_BETWEEN(SYSDATE,DOJ)/12) || years of experience “Programmer” FROM PROGRAMMER WHERE SEX = M UNION SELECT Ms. || PNAME || - has || TRUNC (MONTHS_BETWEEN (SYSDATE,DOJ)/12) || years of experience “Programmer” FROM PROGRAMMER WHERE SEX = F;
0 comments:
Post a Comment