Sie sind auf Seite 1von 12

RDBMS

LAB - SQL Char(10) Not Null, Char(10) Not Null, Char(5) Not Null, Number(10,2) Not Null)

PAGE 1 OF 4

Create table Studies (pname splace course ccost

PNAME SPLACE COURSE CCOST -------------------------------------------------------------------------------------Anand Sabhari PGDCA 4500.00 Altaf COLT DCA 7200.00 Julian BITS MCA 22000.00 Kamala Pragathi DCP 5000.00 Mary Sabhari PGDCA 4500.00 Nelson Pragathi DAP 6200.00 Partick Pragathi DCAP 5200.00 Qadir Apple HDCP 4500.00 Ramesh Sabhari PGDCA 4500.00 Rebecca Brilliant DCA&P 11000.00 Remitha BDPS DCS 6000.00 Revathi Sabhari DAP 5000.00 Vijaya BDPS DCA 48000.00 ----------------------------------------------------------------------------------------------------------------------Create table Software (pname title dev_in scost dcost sold Char(10) Char(20) Char(8) Number(10,2) Number(10,2) Number(10,2) Not Null, Not Null, Not Null, Not Null, (selling cost) Not Null, (development cost) Not Null)

PNAME TITLE DEV_IN SCOST DCOST SOLD --------------------------------------------------------------------------------------------------------------------------------Anand Parachutes Basic 399.95 6000.00 43 Anand Video Titling pack Pascal 7500.00 16000.00 9 Anand System Software C 400.00 24000.00 10 Juliana Inventory control COBOL 3000.00 3500.00 0 Kamala Payroll package Dbase 9000.00 20000.00 7 Mary Financial Acc S/W Oracle 18000.00 85000.00 4 Mary Code Generator C 4500.00 20000.00 23 Partick Read Me C++ 300.00 1200.00 84 Qadir Bombs Away Assembly 750.00 5000.00 11 Qadir Vaccines C 1900.00 3400.00 21 Ramesh Hotel Management Dbase 12000.00 35000.00 4 Ramesh Dead Lee Pascal 599.95 4500.00 73 Remitha PC Utilities C 725.00 5000.00 51 Remitha TSR Help Package Assembly 2500.00 6000.00 6 Revathi Hotel Management Pascal 1100.00 75000.00 2 Revathi Quiz Master Basic 3200.00 2100.00 15 Vijaya ISK Editor C 900.00 700.00 6 -------------------------------------------------------------------------------------------------------------------------------------

Create table

Programmer (pname dob doj sex prof1 prof2 salary

Char(10) Not Null, Datetime Not Null, Datetime Not Null, Char(1) Not Null, Char(8) Not Null, Char(8) Not Null, Number(10,2) Not Null)

PAGE 2 OF 4

PNAME DOB DOJ SEX PROF1 PROF2 SALARY ----------------------------------------------------------------------------------------------------------------------------------Anand 21-Apr-66 21-Apr-92 M Pascal Basic 3200.00 Altaf 02-Jul-64 13-Nov-90 M Clipper COBOL 2800.00 Juliana 31-Jan-68 21-Apr-90 F COBOL Dbase 3000.00 Kamala 30-Oct-68 2-Jan-92 F C Dbase 2900.00 Mary 24-Jun-70 1-Feb-91 F C++ Oracle 4500.00 Nelson 11-Sep-65 11-Oct-89 M COBOL Dbase 2500.00 Partick 10-Nov-65 21-Apr-90 M Pascal Clipper 2800.00 Qadir 31-Aug-65 21-Apr-90 M Assembly C 3000.00 Ramesh 3-May-67 28-Feb-91 M Pascal Dbase 3200.00 Rebecca 1-Jan-67 1-Dec-90 F Basic COBOL 2500.00 Remitha 19-Apr-70 20-Apr-93 F C Assembly 3600.00 Revathi 2-Dec-69 2-Jan-92 F Pascal Basic 3700.00 Vijaya 14-Dec-65 2-May-92 F Foxpro C 3500.00 ---------------------------------------------------------------------------------------------------------------------------------------------

Queries - I
1. Find out the selling cost average for packages developed in Pascal. select AVG(scost) from Software where dev_in='Pascal'; Ans: 3066.65 2. Display the names and ages of all programmers Ans : select pname,(round(months_between(sysdate,dob)/12))"age" from programmer; Ans1: select pname,((sysdate-to_date(dob))/365)"age" from programmer; 3. Display the names of those who have done the DAP course Query: select * from Studies where course='DAP'; 4.What is the highest number of copies sold by a package ? Ans: select max(sold) from Software; 5. Display the names and date of birth of all programmers born in January. Ans: . select * from Programmer where substr(to_char(DOB),4,3)='JAN'; 6. Display the lowest course fee. Ans: select min(ccost) from Studies; 7. How many programmers have done the PGDCA Course ? Ans: select count(*) from Studies where COURSE='PGDCA'; 8. How much revenue has been earned through the sales of packages developed in C ? Ans: select sum(scost*sold) from software where dev_in='C'; 9. Display the details of software developed by Ramesh . Ans : select title from software where pname='Ramesh'; 10. How many programmers studied at SABHARI ? Ans: select count(*) from studies where pname in (select distinct pname from programmer) and splace='Sabhari'; 11. Display the details of packages whose sales crossed the 2000 mark . Ans: select * from software where (scost*sold)>2000;

12. Find out the number of copies which should be sold in order to recover the development cost of each package. Ans: select title,(round(dcost/scost))"count" from software; 13. Display the details of packages for which development cost has been recovered ? Ans: select * from software where dcost>(scost*sold); 14. What is the price of costliest software developed in BASIC ? Ans: select max(scost) from software where dev_in='Basic'; 15. How many packages were developed in Dbase ? Ans: select count(*) from software where dev_in='Dbase'; 16. How many programmers studied at PRAGATHI ? ANS: select count(*) from studies where pname in (select distinct pname from programmer) and splace='Pragathi'; 17. How many programmers paid 5000 to 10000 for their course ? ANS: select count(*) from studies where pname in (select distinct pname from programmer) and ccost between 5000 and 10000; 18. What is the average course fee ? Ans: select avg(ccost) from Studies; 19. Display the details of programmers knowing C ? Ans: select * from Programmer where prof1='C' or prof2='C'; 20. How many programmers know either COBOL or Pascal ? Ans: select count(*) from programmer where prof1 in ('Pascal','Cobol') or prof2 in ('Pascal','Cobol');
21. How many programmers dont know Pascal and C Ans : select count(*) from programmer where prof1 not in ('Pascal','C') and prof2 not in ('Pascal','C'); 22. How old is the oldest male programmer ? Ans: select max((sysdate-to_date(DOB))/365) from programmer where sex=M; 23. What is the average age of female programmers ? Ans: select avg((sysdate-to_date(DOB))/365) from programmer where sex='F'; 24.Calculate the experience in years for each programmers and display along with their names in descending order . Ans : select pname,(round(months_between(sysdate,doi)/12))"Experience" from programmer descending order by (round(months_between(sysdate,doi)/12)); 25. Who are the programmers who celebrate their birthdays during current month ? Ans: select pname from programmer where substr(DOB,4,3)='JAN'; 26. How many female programmers are there ? select count(*) from programmer where sex='F'; 27. What are the languages known by the male programmers ? Ans: select pname,prof1,prof2 from programmer where sex='M' order by pname; 28. What is the average salary ? select avg(salary) from programmer; 29, How many people draw 2000 to 4000 ? select count(*) from programmer where salary between 2000 and 4000; 30. Display the details of those who dont know CLIPPER, COBOL or Pascal . Ans: select pname from programmer where prof1 not in

('Clipper','COBOL','Pascal') and prof2 not in ('Clipper','COBOL','Pascal' 31. Display the cost of the package developed by each programmer. Ans: select pname,dcost from software where pname in (select distinct pname from programmer); 32. Display the sales values of packages developed by each programmer. Ans: select pname,(scost*sold)"Sales Value" from software where pname in (select distinct pname from programmer); 33. Display the number of packages sold by each programmer. Ans: select pname,sum(sold) from software group by pname; 34. Display the sales cost of the packages developed by each programmer language-wise. Ans: select pname,dev_in,scost from software where pname in (select distinct pname from programmer) order by dev_in; 35. Display each language name with average development cost, average selling cost and average price per copy. Ans: select dev_in,avg(dcost),avg(scost),avg(dcost)-avg(scost) from software group by dev_in; 36. Display each programmers name, costliest and cheapest package developed ? Ans: select pname,max(dcosr),min(dcosr) from software group by pname; 37. Display each Institute name with number of course and course fee average. Ans: select splace,count(course),avg(ccost) from studies group by splace; 38. Display each institute name with number of students. Ans: select splace,count(pname) from studies group by splace; 39. Display the names of male and female programmers. Ans: select pname from programmer order by sex; 40. Display the programmers name and their packages. Ans : select distinct pname,title from software ; 41. Display the number of packages in each language except C and C++ Ans: select distinct(dev_in),count(dev_in) from software where dev_in not in('C','C++') group by dev_in; 42. Display the number of packages in each language for which development cost is less than 1000 Ans: select distinct dev_in,count(dev_in) from software where dcosr<1000 group by dev_in; 43. Display the average difference between scost and dcost for each language. Ans: select distinct dev_in,avg(dcost-scost) from software group by dev_in; 44. Display the total scost, dcost and the amount to be recovered for each programmer Ans: select distinct pname,sum(scost),sum(dcosr),(sum(dcosr)-sum(scost)) from software group by pname; 45. Display the highest , lowest and average salaries for those earning more than 2000 Ans : select max(salary),min(salary),avg(salary) from programmer where salary in (select salary from programmer where salary>2000); or select max(salary),min(salary),avg(salary) from programmer where salary>2000; PAGE 3 OF 4

Queries II

1. Who is the highest paid C Programmer ? Ans: select pname,salary from programmer where salary=(select max(salary) from programmer where prof1='C' or prof2='C'); 2. Who is the highest paid female COBOL Programmer ? Ans: select pname,salary from programmer where salary=(select max(salary) from programmer where prof1='Cobol' or prof2='Cobol') and sex='F'; 3. Display the names of the highest paid programmer for each language (Prof1) Ans: select pname,prof1,salary from programmer l where salary in (select max(salary) from programmer where l.prof1=prof1); 4.Who is the least experienced programmer ? Ans: select pname,round(months_between(sysdate,doi)/12) from programmer where round(months_between(sysdate,doi)/12)= (select min(round(months_between(sysdate,doi)/12)) from programmer); 5. Who is the most experienced programmer ? Ans: select pname,months_between(sysdate,doi)/12 from programmer where (months_between(sysdate,doi)/12)= (select max(months_between(sysdate,doi)/12) from programmer); 6. Which language is known by only one programmer. Ans: (select prof1 from programmer group by prof1 having count(prof1)=1 minus select prof2 from programmer) union (select prof2 from programmer group by prof2 having count(prof2)=1 minus select prof1 from programmer); Ans 1: (select prof1 from programmer group by prof1 having count(prof1)=1 minus (select prof2 from programmer)) union (select prof2 from programmer group by prof2 having count(prof2)=1 minus (select prof1 from programmer)); 7. Who is the above programmer ? Ans: select pname,prof2 from programmer where prof2 in ((select prof2 from programmer group by prof2 having count(prof2)=1 minus (select prof1 from programmer)) union select pname,prof2 from programmer where prof2 in ((select prof2 from programmer group by prof2 having count(prof2)=1 minus (select prof1 from programmer)) ; 8. Who is the youngest programmer knowing dBase ? Ans: select pname from programmer where (months_between(sysdate,dob)/12)= (select min(months_between(sysdate,dob)/12) from programmer where prof1='Dbase' or prof2='Dbase'); 9. Which female programmer earns more than 3000/- but does not know C, C++ Oracle or Dbase ? Ans: select pname from programmer where salary>3000 and sex='F' and prof1 not in('C','C++','Oracle','Dbase') and prof2 not in('C','C++','Oracle','Dbase'); 10. Which institute has most number of students ? Ans: select splace,count(splace)"No.of.Students" from studies

where splace in(select max(splace) from studies ) group by splace; 11. Which course has been done by most of the students ? Ans: select course,count(*) from studies group by course having count(course)= (select max(count(course)) from studies group by course); 12. Display the name of the institute and course which has course fee below average. Ans: select distinct splace,course from studies where ccost<(select avg(ccost) from studies); 13. Which is the costliest course ? Ans: select course from studies where ccost=(select max(ccost) from studies); 14. Which institute conducts the costliest course ? Ans: select splace from studies where ccost=(select max(ccost) from studies); 15. Which course has below average number of students ? Ans: select course,count(course) from studies group by course having count(course)<(select avg(count(course)) from studies group by course); 16. Which institute conducts the above course ? Ans: select splace,course from studies where course in (select course from studies group by course having count(course)<(select avg(count(course)) from studies group by course)); 17. Display the names of the course whose fees are within 1000 (+ or -) of the average fee. Ans: select course,ccost from studies where ccost<(select avg(ccost) from studies)+1000 and ccost>(select avg(ccost) from studies)-1000; 18. Which package has the highest development cost ? Ans: select title from software where dcosr= (select max(dcosr) from software); 19. Which package has the lowest selling cost ? Ans: select title from software where scost= (select min(scost) from software); 20. Who developed the package which has sold the least number of copies ? Ans: select pname from software where sold= (select min(sold) from software); 21. Which language was used to develop the package which has the highest sales amount ? Ans: select dev_in from software where scost=(select max(scost) from software); 22. How many copies of the package that has the least difference between development and selling cost were sold ? Ans: select pname,sold from software where dcosr-scost= (select min(dcosr-scost) from software); 23. Which is the costliest package developed in Pascal ? Ans: select * from software where dcosr=(select max(dcosr) from software where dev_in='Pascal');

24. Which language was used to develop the most number of packages ? Ans: select dev_in from software group by dev_in having count(dev_in)= (select max(count(dev_in)) from software group by dev_in); 25. Which Programmer has developed the highest number of packages ? Ans: select pname,count(pname) from software group by pname having count(pname) = (select max(count(pname)) from software where pname in (select pname from programmer) group by pname); 26. Who is the author of the costliest package ? Ans: select pname from software where dcosr= (select max(dcosr) from software); 27. Display the names of packages which have been sold less than the average number of packages. Ans: select title,sold from software where sold< (select avg(sold) from software); 28. Who are the authors of packages which have recovered more than double the development cost ? Ans: select distinct pname from software where (scost*sold*2)>dcosr; 29. Display the programmer names and the cheapest package developed by them in each language ? Ans: select pname,min(dcosr) from software group by pname; 30. Display the language used by each programmer to develop the highest selling and lowest selling package. Ans: select pname,dev_in from software l where sold in (select max(sold) from software where l.pname=pname) or sold in (select min(sold) from software where l.pname=pname) order by pname; 31. Who is the youngest male programmer born in 1965 ? Ans: select pname,dob from programmer where dob=(select min(dob) from programmer where to_char(dob,'YY')=65 and sex='M'); 32. Who is the oldest female programmer born 1n 1965 ? Ans: select pname,dob from programmer where dob=(select max(dob) from programmer where to_char(dob,'YY')=65 and sex='F'); 33. In which year were the most number of programmers born ? Ans: select to_char(dob,'YYYY') from programmer group by to_char(dob,'YYYY') having count(to_char(dob,'YYYY'))= (select max(count(to_char(dob,'YYYY'))) from programmer group by (to_char(dob,'YYYY'))); 34. In which month did most number of programmers join ? Ans: select to_char(doi,'MON') from programmer group by to_char(doi,'MON') having count(to_char(doi,'MON'))= (select max(count(to_char(doi,'MON'))) from programmer group by (to_char(doi,'MON')));

35. In which language are most of the programmers proficient ? Ans: select prof1 from (select pname,prof1 from programmer union select pname,prof2 from programmer) group by prof1 having count(pname)= (select max(count(prof1)) from (select pname,prof1 from programmer union select pname,prof2 from programmer) group by prof1); 36. Who are the male programmers earning below the average salary of the female programmers ? Ans : select * from programmer where sex='M' and salary<(select avg(salary) from programmer where sex='F'); 37. Who are the female programmers earning more than the highest paid male programmer ? Ans: select * from programmer where sex='F' and salary>(select max(salary) from programmer where sex='M'); 38. Which language has been stated as prof1 by most of the programmers ? Ans: select prof1 from programmer group by prof1 having count(prof1)=(select max(count(prof1)) from programmer group by prof1);

PAGE 4 OF 4

Queries III
1. Display the details of those who are drawing the same salary. Ans: select pname,salary from programmer l where salary= (select salary from programmer where salary=l.salary and not pname=l.pname) order by salary; 2. Display the details of the software developed by the male programmers earning more than 3000. Ans: select * from software where pname in (select pname from programmer where salary>3000 and sex='M'); 3. Display the details of packages developed in PASCAL by female programmers. Ans: select * from software where dev_in='Pascal' and software.pname in (select pname from programmer where sex='F'); 4. Display the details of the programmers who joined before 1990. Ans: select * from programmer where to_char(DOI,'yy')=90; 5. Display the details of Software developed in C by female programmers of PRAGATHI Ans: select * from software where dev_in='C' and software.pname in (select pname from programmer where pname in (select pname from studies where splace='Pragathi') and sex='F'); 6. Display the number of packages, number of copies sold and sales value of each programmer institute-wise.

Ans: select x.splace, y.pname, count(y.title)"No.of Software", sum(y.sold)"No.of copies", sum(y.scost * y.sold)"Sales value" from software y, studies x where x.pname = y.pname group by y.pname, x.splace order by x.splace; 7. Display the details of software developed in DBase by male programmers who belong to the institute in which most number of programmers studied. Ans: select pname from software where pname in (select pname from programmer where pname in (select pname from studies where splace= (select splace from studies having count(splace)= (select max(count(splace)) from studies group by splace) group by splace)) and sex='M') and dev_in='Dbase'; 8. Display the details of software that was developed by male programmers born before 1965 and female programmers born after 1975. Ans: select * from software where pname in ((select pname from programmer where sex='M' and to_char(dob,'YYYY')<1965 ) union (select pname from programmer where sex='F' and to_char(dob,'YYYY')>1975 )); 9. Display the details of the software developed by male students of Sabhari Ans: select * from software where pname in (select pname from studies where splace='Sabhari'); 10. Display the names of programmers who have not developed any package. Ans: select distinct pname from programmer where pname not in (select distinct pname from software); 11. What is the total cost of the software developed by the programmers of APPLE. Ans: select sum(dcosr) from software where pname in (select distinct pname from studies where splace='Apple'); 12. Who are the programmers who joined in the same day. Ans: select x.pname,y.pname, x.doi from programmer x,programmer y where x.pname < y.pname and x.doi = y.doi order by x.pname, y.pname; 13. Who are the programmers who have the same prof2. Ans: select x.pname, y.pname,x.prof2 from programmer x,programmer y where x.prof2=y.prof2 and x.pname<y.pname order by x.pname,y.pname; 14. Display the total sales value of software, institute-wise. Ans: select s.splace,sum(sft.sold*sft.scost) from software sft, studies s where s.pname=sft.pname group by s.splace; 15. In which institute did the person who developed the costliest package study. Ans: select software.pname,studies.splace from software,studies where dcosr= (select max(dcosr) from software) and software.pname=studies.pname; 16. Which language listed in Prof1 and Prof2 has not been used to develop any package. Ans: (select prof1 "Language" from programmer union select prof2 from programmer) minus (select dev_in from software);

17. How much does the person who developed the highest selling package earn, and what course did he/she undergo. Ans: select programmer.pname, studies.course, programmer.salary from programmer,software,studies where software.sold= (select max(sold) from software) and software.pname=programmer.pname and studies.pname=software.pname; 18. How many months will it take for each programmer to recover the cost of the course underwent.? Ans: select programmer.pname,round(studies.ccost/programmer.salary) from programmer,studies where programmer.pname=studies.pname; 19. Which is the costliest package developed by a person with under 3 year experience. Ans: select pname,title from software where dcosr= (select max(dcosr) from software where pname in (select pname from programmer where round(months_between(sysdate,doi)/12)<3)); 20. What is the average salary for those whose softwares sales value is more than 50,000. Ans: select avg(salary) from programmer where pname in (select distinct pname from software where (sold*scost)>50000); 21. How many packages were developed by the students who studied in institute that charge the lowest course fee. Ans: select count(pname) from software where pname in (select pname from studies where ccost=(select min(ccost) from studies)); 22. How many packages were developed by the person who developed the cheapest package. Where did he/she study. Ans : select software.pname,studies.splace from software,studies where dcosr=(select min(dcosr) from software) and software.pname=studies.pname; 23. How many packages were developed by female programmers earning more than highest paid male programmer. Ans: select pname,count(pname)"Package Count" from programmer where sex='F'and salary>(select max(salary) from programmer where sex='M') group by pname; 24. How many packages were developed by the most experienced programmers from BDPS ? Ans: select pname,count(pname) from programmer where doi= (select min(doi) from programmer where pname in (select pname from studies where splace='BDPS')) group by pname; 25. List the programmers (from the software table) and the institutes they studied, including those who did not develop any package. Ans: select distinct sft.pname, s.splace from studies s,software sft where sft.pname=s.pname union select pname,splace from studies; 26. List the programmer names (from the programmer table) and the number of packages each developed. Ans: select pname,count(pname)"No.Of.Packages" from software group by pname; 27. Display the details of those who will be completing 2 years of service this year. Ans: select pname from programmer where

(round(months_between(sysdate,doi)/12)=2); 28. Calculate the amount to be recovered for those packages whose development cost has not been recovered. Ans: select title,(dcosr-(scost*sold)) from software where dcosr>(scost*sold); 29. List the packages which have not been sold so far. Ans: select title from software where sold=0; 30. Find out the cost of the software developed by Mary. Ans: select sum(dcosr) from software where pname='Mary' 31. Display the institutes from the studies table without duplicates. Ans: select distinct splace from studies; 32. How many different courses are mentioned in the studies table. Ans: select count(distinct course) from studies; 33. Display the names of programmers whose names contain 2 occurences of the letter A. Ans: select pname from software where pname like '%a%a%' or pname like '%A%a%'; 34. Display the names of the programmers whose names contain upto 5 characters. Ans: select pname from programmer where length(pname)<=5; 35. How many female programmers knowing COBOL have more than 2 years experience. Ans: select pname from programmer where 'COBOL' in (prof1,prof2) and sex='F' and round(months_between(sysdate,doi)/12)>2; 36. What is the length of the shortest name in the programmer table. Ans: select pname,length(pname) from programmer where length(pname)=(select min(length(pname)) from programmer); 37. What is the average development cost of a package developed in COBOL ? Ans: select avg(dcosr) from software where dev_in='COBOL'; 38. Display the name, sex, DOB, (dd/mm/yy), DOJ for all the programmers without using the conversion function. Ans: SELECT PNAME"Name",sex, SUBSTR(DOB,1,2)||'/'||DECODE(SUBSTR(DOB,4,3),'JAN','01','FEB','02', 'MAR','03','APR','04','MAY','05','JUN','06','JUL','07','AUG','08','SEP','09','OCT','10','NOV','11','DEC','12')||'/'|| SUBSTR(DOB,8,4)"DOB",SUBSTR(DOI,1,2)||'/'|| DECODE(SUBSTR(DOI,4,3),'JAN','01','FEB','02','MAR','03','APR','04','MAY','05','JUN','06','JUL','07','AUG','08 ','SEP','09','OCT','10','NOV','11','DEC','12')||'/'||SUBSTR(DOI,8,4) "DOJ" FROM PROGRAMMER; 39. Who are the programmers who were born on the last day of the month. Ans: select pname,dob from programmer where dob=last_day(dob); 40. What is the amount paid in salaries of the male programmers who do not know COBOL Ans: select sum(salary) from programmer where pname not in (select pname from programmer where sex='M' and prof1 in('COBOL') or prof2 in ('COBOL')) and sex='M' ;
Ans1:

select sum(salary)"Total Salary" from programmer where 'COBOL' not in (prof1,prof2) and sex = 'M';

41. Display the title, scost, dcost and difference between scost and dcost in descending order of difference. Ans: select title,scost,dcosr,(scost-dcosr) from software descending order by (scost-dcosr); 42. Display the names of the packages whose names contain more than one word. Ans: select title from software where title like '% %';

43. Display the name, job, DOB, DOJ of those , month of birth and month of joining are the same. Ans: select pname,dob,doi from programmer where to_char(dob,'mon')=to_char(doi,'mon');

Insertion:

------------------------================================-------------------------

Studies: insert into studies values('Anand','Sabhari','PGDCA',4500.00); insert into studies values('Altaf','COLT','DCA',7200.00); insert into studies values('Julian','BITS','MCA',22000.00); insert into studies values('Kamala','Pragathi','DCP',5000.00); insert into studies values('Mary','Sabhari','PGDCA',4500.00); insert into studies values('Nelson','Pragathi','DAP',6200.00); insert into studies values('Partick','Pragathi','DCAP',5200.00); insert into studies values('Qadir','Apple','HDCP',4500.00); insert into studies values('Ramesh','Sabhari','PGDCA',4500.00); insert into studies values('Rebecca','Brilliant','DCAnP',11000.00); insert into studies values('Remitha','BDPS','DCS',6000.00); insert into studies values('Revathi','Sabhari','DAP',5000.00); insert into studies values('Vijaya','BDPS','DCA',48000.00); Software: insert into Software values('Anand','Parachutes','Basic',399.95,6000.00,43); insert into Software values('Anand','Video Titling pack','Pascal',7500.00,16000.00,9); insert into Software values('Anand','System Software','C',400.00,24000.00,10); insert into Software values('Juliana','Inventory control','COBOL',3000.00,3500.00,0); insert into Software values('Kamala','Payroll package','Dbase',9000.00,20000.00,7); insert into Software values('Mary','Financial Acc S/W','Oracle',18000.00,85000.00,4); insert into Software values('Mary','Code Generator','C',4500.00,20000.00,23); insert into Software values('Partick','Read Me','C++',300.00,1200.00,84); insert into Software values('Qadir','Bombs Away','Assembly',750.0,5000.00,11); insert into Software values('Qadir','Vaccines','C',1900.00,3400.00,21); insert into Software values('Ramesh','Hotel Management','Dbase',12000.00,35000.00,4); insert into Software values('Ramesh','Dead Lee','Pascal',599.95,4500.00,73); insert into Software values('Remitha','PC Utilities','C',725.00,5000.00,51); insert into Software values('Remitha','TSR Help Package','Assembly',2500.00,6000.00,6); insert into Software values('Revathi','Hotel Management','Pascal',1100.00,75000.00,2); insert into Software values('Revathi','Quiz Master','Basic',3200.00,2100.00,15); insert into Software values('Vijaya','ISK Editor','C',900.00,700.00,6); Programmer: insert into programmer values('Anand','21-Apr-66','21-Apr-92','M','Pascal','Basic',3200.00); insert into programmer values('Altaf','02-Jul-64','13-Nov-90','M','Clipper','COBOL',2800.00); insert into programmer values('Juliana','31-Jan-68','21-Apr-90','F','COBOL','Dbase',3000.00); insert into programmer values('Kamala','30-Oct-68','2-Jan-92','F','C','Dbase',2900.00); insert into programmer values('Mary','24-Jun-70','1-Feb-91','F','C++','Oracle',4500.00); insert into programmer values('Nelson','11-Sep-65','11-Oct-89','M','COBOL','Dbase',2500.00); insert into programmer values('Partick','10-Nov-65','21-Apr-90','M','Pascal','Clipper',2800.00); insert into programmer values('Qadir','31-Aug-65','21-Apr-90','M','Assembly','C',3000.00); insert into programmer values('Ramesh','3-May-67','28-Feb-91','M','Pascal','Dbase',3200.00); insert into programmer values('Rebecca','1-Jan-67','1-Dec-90','F','Basic','COBOL',2500.00); insert into programmer values('Remitha','19-Apr-70','20-Apr-93','F','C','Assembly',3600.00); insert into programmer values('Revathi','2-Dec-69','2-Jan-92','F','Pascal','Basic',3700.00); insert into programmer values('Vijaya','14-Dec-65','2-May-92','F','Foxpro','C',3500.00);

Note: -- length(pname) works only when pname is VARCHAR. - update studies set course='DCA' where pname='Rebecca';

Das könnte Ihnen auch gefallen