Está en la página 1de 6

Display the names of those who have done the DAP course.

select pname from studies where course='DAP


PNAME
---------SANKAR
SIVA
NARAYANAN

What is the highest number of copies sold by a package?

select title,sold/scost copies from software where sold/scost in (select


max(sold/scost) from software)
TITLE
-------------------EXCEL
2 IMAGEPROCESSING

COPIES
---------20
20

Display the names and date of birth of all programmers born in January?

select pname,dob from programmer where


trim(to_char(dob,'month'))='january'

PNAME
DOB
---------- --------NITIN
10-JAN-83
Display the lowest course fee

select course,ccost from studies where ccost=(select min(ccost) from


studies) group by course,ccost;
COURS
----PCP

CCOST
---------6000

4
How many programmers have done the PGDCA course?

select pname from studies where course='PGDCA';


PNAME
--------SENTHIL
NITIN
TOM

select count(*) count from studies where course='PGDCA';


COUNT
------3
5

Classification: Sensitive

How much revenue has been earned thru the sales of package developed in C?

select sum(sold-dcost) revenue, dev_in from software where dev_in='C'


group by dev_in

REVENUE DEV_IN
-------------49000
C
Display the details of packages whose sales crossed the 2000 mark?

select * from software where scost>2000;

PNAME
TITLE
DEV_IN
SCOST
DCOST
SOLD
---------- -------------------- -------- ---------- ---------- ---------SENTHIL POWERPOINT
C++
3000
5000
15000
NITIN
VISUALBASIC
JAVA
4000
30000
20000
KANDAN EXCEL
ACCESS
4000
12000
8000
How many programmers paid 5000 to 10000 for their course?

select pname, course from studies where ccost between 5000 and 10000;

PNAME
COURS
-------------SANKAR
DAP
SIVA
DAP
TINKU
DPA
MARTIN
DPA
TOM MOODY PCP
What is the average course fee?

select avg(ccost) from studies;

AVG(CCOST)
---------11444.4444
How many programmers know either COBOL or PASCAL?

select count(pname) count from programmer where prof1 in


('COBOL','PASCAL') or prof2 in ('COBOL','PASCAL');

10

COUNT
------4
How old is the oldest male programmer?

select round(to_char((sysdate-(select min(dob) from programmer where


sex='M' ))/365)) age from dual;
11

AGE
---------43

Classification: Sensitive

Display the sales values of packages developed by each programmer

select pname, scost, title from software group by pname, scost, title;

12

PNAME
SCOST TITLE
---------- ---------- -------------------KANDAN
4000 EXCEL
NARAYANAN
2000 IMAGEPROCESSING
NITIN
4000 VISUALBASIC
RITA
2000 EXCEL
SANKAR
1000 WEBPAGE
SANKAR
2000 EXCEL
SANKAR
2000 WORD PROCESSOR
SENTHIL
3000 POWERPOINT
SIVA
1000 EXCEL
Display number of packages sold by each programmer

select pname,(sold/scost) sold from software group by pname, sold/scost

13

PNAME
SOLD
------------------KANDAN
2
NARAYANAN
20
NITIN
5
RITA
6
SANKAR
5
SANKAR
10
SENTHIL
5
SIVA
20
Display each language name with average development cost, average selling cost and average price per
copy

select dev_in, avg(dcost),avg(scost),avg(sold/scost) from software group


by dev_in;

14
15

DEV_IN AVG(DCOST) AVG(SCOST) AVG(SOLD/SCOST)


---------------------------------------ACCESS
8000
3000
4
C
7000
2000
10
C++
5000
3000
5
HTML
10000
1000
5
JAVA
30000
4000
5
ORACLE
3000
1000
20
Display each programmers name, costliest and cheapest package developed.

select pname, dev_in, max(dcost) max, min(dcost) min from software group
by pname, dev_in
PNAME
DEV_IN
MAX
MIN
---------- -------- ---------- ---------KANDAN ACCESS
12000
12000

Classification: Sensitive

NARAYANAN C
4000
4000
NITIN
JAVA
30000
30000
RITA
ACCESS
4000
4000
SANKAR C
10000
7000
SANKAR HTML
10000
10000
SENTHIL C++
5000
5000
SIVA
ORACLE
3000
3000
Display each institute name with number of students.

select count(pname),splace from studies group by splace;

16

COUNT SPLACE
-------------3
BANGALORE
2
CHENNAI
1
MADURAI
2
TIRUNELVLI
1
TRIVANDRUM
Display the average difference between scost and dcost for each language

select dev_in as Language, abs(avg(scost-dcost)) as Difference from


software group by dev_in;

17

LANGUAGE DIFFERENCE
----------------ACCESS
3666.66667
C
6000
C++
2000
HTML
9000
JAVA
26000
ORACLE
2000
Display the total scost, dcost and the amount to be recovered for each programmer for those, whose
dcost has not yet been recovered

select pname, sum(scost) TOTAL, dcost, dcost-sold "TO BE RECOVERED"


from software where sold<dcost group by pname, dcost, dcost-sold;

18

PNAME
TOTAL
DCOST
TO BE RECOVERED
------------------- -----------------------KANDAN
4000
12000
4000
NITIN
4000
30000
10000
SANKAR
1000
10000
5000
Display the highest, lowest and average salaries for those earning more than 2000

select max(salary) max, min(salary) min, avg(salary) avg from programmer


where salary>2000;

19

MAX
MIN
AVG
---------- ---------- ---------30000
15000 20714.2857
Classification: Sensitive

Who is the highest paid C programmer?

select pname, salary from (select * from programmer where salary=(select


max(salary) from programmer where (prof1='C' or prof2='C')))

20

PNAME
SALARY
---------- ---------NARAYANAN
25000
Who is the highest paid female COBOL programmer?

select pname,max(salary) max from programmer where sex='F' and


prof1='HTML' or prof2='HTML' group by pname

21

PNAME
MAX
------------------RITA
30000
Display the name of the highest paid programmer for each language (prof1)

select pname,salary,prof1 from programmer where (prof1,salary) in (select


prof1,max(salary) from programmer group by prof1)
PNAME
---------NARAYANAN
SENTHIL
SIVA
KUMAR
22 RITA

SALARY PROF1
---------- -------25000
C
15000
C++
15000
JAVA
20000
JSP
30000
ORACLE

Who is the least experience programmer?

select pname, doj from programmer where doj=(select max(doj) from


programmer);

23

PNAME
DOJ
---------- --------RITA
03-NOV-06
Display the details of the software that was developed by male programmers born before 1965 and
female programmers born after 1975

select * from software where pname in (select pname from programmer


where sex='M' and to_char(dob, 'YYYY')<1983) or pname in (select pname
from programmer where sex='F' and to_char(dob, 'YYYY')>1975);

24

PNAME
TITLE
DEV_IN
SCOST
DCOST
SOLD
---------- -------------------- -------- ---------- ---------- ---------SENTHIL POWERPOINT
C++
3000
5000
15000
SIVA
EXCEL
ORACLE
1000
3000
20000
RITA
EXCEL
ACCESS
2000
4000
12000

Classification: Sensitive

Display the name of programmers who have not developed any package.

select pname from programmer where pname not in (select pname from
software) group by pname

25

PNAME
------KUMAR

Classification: Sensitive

También podría gustarte