Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
73 views

SQL Queries

The document describes three tables created in a database - PROGRAMMER, SOFTWARE, and STUDIES. The PROGRAMMER table contains details of programmers like name, date of birth, date of joining, gender, proficiencies, and salary. The SOFTWARE table contains details of software packages developed by programmers, including name, title, development language, selling cost, development cost, and units sold. The STUDIES table contains education details of programmers like name, place of study, course, and course fees. Several insert statements populate the tables with data. Queries are then written to retrieve information from these tables.

Uploaded by

mesmeralan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

SQL Queries

The document describes three tables created in a database - PROGRAMMER, SOFTWARE, and STUDIES. The PROGRAMMER table contains details of programmers like name, date of birth, date of joining, gender, proficiencies, and salary. The SOFTWARE table contains details of software packages developed by programmers, including name, title, development language, selling cost, development cost, and units sold. The STUDIES table contains education details of programmers like name, place of study, course, and course fees. Several insert statements populate the tables with data. Queries are then written to retrieve information from these tables.

Uploaded by

mesmeralan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

FIRST TABLE-

PROGRAMMER

create table PROGRAMMER(name varchar(10), DOB date, DOJ date, SEX varchar(1), PROF1 varchar(10),
PROF2 varchar(10), SALARY number(5));
insert into PROGRAMMER VALUES('ANAND','21-APR-66','02-MAY-02','M','PASCAL','BASIC','3200');
insert into PROGRAMMER VALUES('ALTAF','02-JUL-64','02-JAN-92','M','CLIPPER','COBOL','2800');
insert into PROGRAMMER VALUES('JAGDISH','06-OCT-70','02-APR-93','M','ORACLE','JAVA','4100');
insert into PROGRAMMER VALUES('JULIANA','31-JAN-68','01-DEC-90','F','COBOL','DBASE','3000');
insert into PROGRAMMER VALUES('KAMLA','30-OCT-68','28-FEB-91','F','C','DBASE','2900');
insert into PROGRAMMER VALUES('MARY','24-JUN-70','21-APR-93','F','C++','ORACLE','4500');
insert into PROGRAMMER VALUES('NELSON','11-SEP-65','21-APR-90','M','COBOL','DBASE','2500');
insert into PROGRAMMER VALUES('PATRIK','19-NOV-65','11-OCT-89','M','PASCAL','CLIPPER','2800');
insert into PROGRAMMER VALUES('QADIR','31-AUG-65','01-FEB-91','M','ASSEMBLY','C','3000');
insert into PROGRAMMER VALUES('RAMESH','03-MAY-67','02-JAN-92','M','PASCAL','DBASE','3200');
insert into PROGRAMMER VALUES('REBECCA','01-JAN-67','21-APR-90','F','BASIC','COBOL','2500');
insert into PROGRAMMER VALUES('REMITHA','19-APR-70','04-OCT-94','F','C','ASSEMBLY','3600');
insert into PROGRAMMER VALUES('REVATHI','02-DEC-69','13-NOV-90','F','PASCAL','BASIC','3700');
insert into PROGRAMMER VALUES('VIJAYA','14-DEC-65','21-APR-92','F','FOXPRO','C','3500');

SECOND TABLE-

SOFTWARE

create table RICHA_SOFTWARE(NAME varchar(10), TITLE varchar(20),DEV_IN varchar(10),SCOST


number(10),DCOST number(10),SOLD number(10));
insert into RICHA_SOFTWARE VALUES('ANAND','PARACHUTES','BASIC','399.95','6000','43');
insert into RICHA_SOFTWARE VALUES('ANAND','VIDEO TILTING PACK','PASCAL','7500.00','16000','9');
insert into RICHA_SOFTWARE VALUES('JAGDISH','SERIAL LINKS UTILITY','ORACLE','800.00','75000','10');
insert into RICHA_SOFTWARE VALUES('JAGDISH','SHARES MANAGEMENT','JAVA','3000.00','12000','14');
insert into RICHA_SOFTWARE VALUES('JULIANA','INVENTORY CONTROL','COBOL','3000.00','3500','0');
insert into RICHA_SOFTWARE VALUES('KAMLA','PAYROLL PACKAGE','ORACLE','9000.00','20000','7');
insert into RICHA_SOFTWARE VALUES('MARY','FINANCIAL ACC SOFTWR','DBASE','18000.00','85000','4');
insert into RICHA_SOFTWARE VALUES('MARY','CODE GENERATOR','C','4500.00','20000','23');
insert into RICHA_SOFTWARE VALUES('MARY','READ ME','C++','300.00','1200','94');
insert into RICHA_SOFTWARE VALUES('MARY','GRAPHIC EDITOR','PASCAL','750.00','5000','11');
insert into RICHA_SOFTWARE VALUES('PATRIK','BOMBS AWAY','ASSEMBLY','499.95','530','114');
insert into RICHA_SOFTWARE VALUES('QADIR','VACCINES','PASCAL','1900.00','3400','21');
insert into RICHA_SOFTWARE VALUES('QADIR','HOTEL MANAGEMENT','C','12000.00','35000','4');
insert into RICHA_SOFTWARE VALUES('RAMESH','DEAD LEE','DBASE','99.95','4500','73');
insert into RICHA_SOFTWARE VALUES('RAMESH','PC UTILITY','PASCAL','725.00','5000','51');
insert into RICHA_SOFTWARE VALUES('REMITHA','TSR HELP PACKAGE','C','2500.00','6000','6');
insert into RICHA_SOFTWARE VALUES('REMITHA','HOTEL
MANAGEMENT','ASSEMBLY','1100.00','75000','2');
insert into RICHA_SOFTWARE VALUES('REVATHI','QUIZ MASTER','PASCAL','3200.00','2100','15');
insert into RICHA_SOFTWARE VALUES('REVATHI','ISK EDITOR','BASIC','900.00','1000','6');
insert into RICHA_SOFTWARE VALUES('VIJAYA','INVENTORY CONTROL','C','725.00','1500','10');

THIRD TABLE-

STUDIES

CREATE TABLE RICHA_STUDIES(NAME VARCHAR(10),SPLACE VARCHAR(10),COURSE


VARCHAR(10),CCOST NUMBER);
INSERT INTO RICHA_STUDIES VALUES('ANAND','SABHARI','PGDCA','4500');
INSERT INTO RICHA_STUDIES VALUES('ALTAF','CCIT','DCA','7200');
INSERT INTO RICHA_STUDIES VALUES('JAGDISH','SSIL','DCA','3500');
INSERT INTO RICHA_STUDIES VALUES('JULIANA','BITS','DCA','22000');
INSERT INTO RICHA_STUDIES VALUES('KAMLA','PRAGATHI','DCP','5000');
INSERT INTO RICHA_STUDIES VALUES('MARY','SABHARI','PGDCA','4500');
INSERT INTO RICHA_STUDIES VALUES('NELSON','PRAGATHI','DAP','6200');
INSERT INTO RICHA_STUDIES VALUES('PATRIK','PRAGATHI','DCAP','5200');
INSERT INTO RICHA_STUDIES VALUES('QADIR','APPLE','HDCP','14000');
INSERT INTO RICHA_STUDIES VALUES('RAMESH','SABHARI','PGDCA','4500');
INSERT INTO RICHA_STUDIES VALUES('REBECCA','BRILLIANT','DCA AND P','11000');
INSERT INTO RICHA_STUDIES VALUES('REMITHA','BDPS','DCS','6000');
INSERT INTO RICHA_STUDIES VALUES('REVATHI','SABHARI','DMP','5000');
INSERT INTO RICHA_STUDIES VALUES('VIJAYA','BDPS','DCA','48000');

SQL QUERIES
Query- Find out the selling cost, average for the packages developed in pascal.

SQL> select avg(SCOST) from richa_software where DEV_IN = 'PASCAL';


AVG(SCOST)
---------2815

Query- Display the names and ages of all the programmers.

SQL> select name, round((sysdate-DOB)/365) from programmer;


NAME

ROUND((SYSDATE-DOB)/365)

---------- -----------------------ANAND

47

ALTAF

49

JAGDISH

42

JULIANA

45

KAMLA

44

MARY

43

NELSON

47

PATRIK

47

QADIR

48

RAMESH

46

REBECCA

46

NAME

ROUND((SYSDATE-DOB)/365)

---------- -----------------------REMITHA

43

REVATHI

43

VIJAYA
14 rows selected.

47

Query- Display the names of those who have done dap course.

SQL> select name from richa_studies where course = 'DAP';


NAME
---------NELSON

Query- Display the highest number of copies sold by a package.

SQL> select max(SOLD) from richa_software;


MAX(SOLD)
---------114

Query- Display name and date of birth of all the programmers born in January.

SQL> select name, DOB from programmer where DOB like '%JAN%';
NAME
DOB
---------- --------JULIANA 31-JAN-68
REBECCA 01-JAN-67

Query- Display the lowest course fee for a course, submitted by any programmer.

SQL> select min(CCOST) from richa_studies;


MIN(CCOST)
---------3500

Query- How many programmers have done PGDCA courses.

SQL> select count(COURSE) from richa_studies where course = 'PGDCA';


COUNT(COURSE)
------------3

Query- How much revenue has been earned through the sale of package developed in C.
SQL> select sum(SCOST) from richa_software where DEV_IN = 'C';
SUM(SCOST)
---------19725

Query- Display the details of software developed by Ramesh.

SQL> select * from richa_software where NAME = 'RAMESH';


NAME
TITLE
DEV_IN
SCOST DCOST
SOLD
---------- -------------------- ---------- ---------- ---------- ---------RAMESH DEAD LEE
DBASE
100
4500
73
RAMESH PC UTILITY
PASCAL
725
5000
51

Query- Display the details of packages whose sale cross 20,000.

SQL> select * from richa_software where SCOST > 20000;


no rows selected

You might also like