You are on page 1of 59

Project Question No.

1
Q1. CREAT TABLE EMPLOYEE WITH THE FOLLOWING STRUCTURE. TABLE : EMPLOYEE
NAME OF COLUMN EMP_ID FIRST_NAME LAST_NAME USER_ID SALARY TYPE INTEGER VARCHAR2(30) VARCHAR2(30) VARCHAR2(10) INTEGER

*EMP_ ID SHOULD BE DECLARED AS PRIMARY KEY. *USER_ID SHOULD BE UNIQUE. *SALARY MUST BE GREATER THAN 5000. *FIRST_NAME AND LAST_NAME MUST NOT REMAIN IN BLANK.

CREAT TABLE EMP ( EMP_ID FIRST_NAME LAST_NAME USER_ID SALARY PRIMARY KEY, INTEGER, VARCHAR2(30), NOT NULL, VARCHAR2(30), NOT NULL, UNIQUE, VARCHAR2(10), INTEGER CHECK(SALARY>5000);

Project Question No. 2


Q2. WRITE SQL COMMANDS FOR THE FOLLOWING ON THE BASIS OF GIVEN TABLE STUDENT TABLE : STUDENT
STUDENT NO. 10 11 12 13 14 15
CLASS NAME

GAME CRICKET TENNIS SWIMMING TENNIS CRICKET SKATTING

GRADE1 SUPW B A B C A A PHOTOGRAPHY GARDENING PHOTOGRAPHY COOKING LITERATURE GARDENING

GRADE2 A C B A A C

7 8 7 7 9 10

VAIBHAV PRABHJOT VIPIN VIJAY DANISH PANKAJ

*DISPLAY ALL THE DETAILS FROM TABLE STUDENT. *DISPLAY THE NAME OF THE STUDENT WHO ARE GETTING C IN EITHER GAME OR SUPW. *DISPLAY THE DIFFERENT GAME OFFERED IN THE SCHOOL. *DISPLAY THE SUPW TAKEN UP BY THE STUDENT, WHOSE NAME STARTS WITH V.

SQL>SELECT*FROM STUDENT; SQL>SELECT NAME FROM STUDENT WHERE GRADE 1 = C OR GRADE 2= C; SQL>SELECT DISTINCT GAME FROM STUDENT; SQL>SELECT SUPW FROM STUDENT EHRE NAME LIKE V;

Project Question No.3


Q3. WRITE SQL COMMANDS FOR THE FOLLOWING ON THE BASIS OF GIVEN TABLE HOSPITAL. TABLE : HOSPITAL
NO. 1 2 3 4 5 6 7 8 8 10 NAME SANDEEP RAVINA KARAN TARUN ZUBIN KETAKI ANKITA ZAREEN KUSH SHAILYA AGE 65 24 45 12 36 16 29 45 19 31 DEPARTMENT SURGERY ORTHOPAEDIC ORTHOPAEDIC SURGERY ENT ENT CARDIOLOGY GYNAECOLOGY CARDIOLOGY NUCLEAR D.O.ADM 23-2-98 20-1-98 15-2-98 01-1-98 12-1-98 24-2-98 20-2-98 22-2-98 13-1-98 19-1-98 CHARGES 300 200 500 300 250 300 800 300 800 400 SEX M F M M M F F F M F

*DISPLAY ALL THE INFORMATION ABOUT THE PATIENTS OF CARDIOLOGY DEPARTMENT. *TO LIST THE NAMES OF FEMALE PATIENTS WHO ARE IN ORTHOPAEDIC DEPARTMENT. *TO LIST NAMES OF ALL PATIENTS WITH THEIR DATE OF ADMISSION IN ASCENDING ORDER.

*DISPLAY PATIENS NAME, CHARGE, AGE OF MALE PATIENS ONLY. *TO COUNT THE NUMBER OF PATIENTS WITH AGE>20. *TO INSERT A NEW ROW IN THE HOSPITAL TABLES WITH THE FOLLOWING DATA: (11, MUSTAFA,37,ENT,25-2-98,250M).

SQL>SELECT*FROM HOSPITAL WHERE DEPARTMENT=CARDIOLOGY; SQL>SELECT NAME FROM HOSPITAL WHERE DEPARTMENT=ORTHOPEADIC AND SEX=F; SQL>SELECT NAME, DOADM. FROM HOSPITAL ORDER BY DOADM ASC; SQL>SELECT NAME, CHARGES, AGE, FROM HOSPITAL WHERE SEX=M; SQL>SELECT COUNT (*) FROM HOSPITAL WHERE AGE>20;

SQL>INSERT INTO HOPITAL VALUES (11, MUSTAFA,37,ENT,25-2-98,250M);

PROJECT QUESTION NO. 4 Q4. WRITE SQL COMMANDS FOR THE FOLLOWING
ON THE BASIS OF GIVEN TABLE SUPPLIER. TABLE : SUPPLIER
S.NO. 51 52 53 54 55 P NAME BREAD CAKE COFFEE CHOCOLATE SAUCE SNAME BRITANNIA BRITANNIA NESCAFE AMUL KISAN QTY 8.00 20.00 45.00 10.00 36.00 CITY DELHI MUMBAI DELHI MUMBAI JAIPUR

*DISPLAY DATA FOR ALL PRODUCT WHOSE QUANTITY IS BETWEEN 170 AND 370. *DISPLAY DATA FOR ALL PRODUCT SORTED BY THEIR QUANTITY. *FIND ALL PRODUCTS THAT HAVE NO SUPPLIER. *GIVE SNAME, PNAME, PRICE FOR ALL THE PRODUCT WHOSE QUANTITY IS<200. *TO DISPLAY S.NO., PNAME, SNAME, QTY IN DESCENDING ORDER OF QUANTITY FROM THE SUPPLIER TABLE.

SQL>SELECT*SUPPLIER WHERE QTY BETWEEN 170 AND 370; SQL>SELECT*FROM SUPPLIER ORDER BY QTY; SQL>SELECT*FROM SUPPLIER WHERE SNAME IS NULL; SQL>SELECT SNAME FROM SUPPLIER WHERE PNAME IS LIKE C%; SQL>SELECT PNAME, SNAME, QTY FROM SUPPLIER ORDER BY QTY DESC;

PROJECT QUESTION NO. 5 Q5. WRITE SQL COMMANDS FOR THE FOLLOWING
ON THE BASIS OF GIVEN TABLE TEACHER TABLE : TEACHER
S.NO. 1 2 3 4 5 6 7 8 NAME JUGAL SHAMILA SANDEEP RAKESH SHYAM SHIV OM SANGEETA SHALAKHA AGE 34 31 32 42 50 44 35 33 DEPARTMENT COMPUTER HISTORY MATHS MATHS HISTORY COMPUTER HISTORY MATHS D.O.ADM 10-01-97 24-03-98 12-12-96 05-09-99 27-06-98 25-02-97 01-07-99 31-07-97 SALARRY 12000 20000 30000 40000 30000 21000 40000 20000 SEX M F M F M M F F

*TO SHOW ALL INFORMATION ABOUT THE TEACHER OF HISTORY DEPARTMENT. *TO LIST THE NAME OF FEMALE TEACHER WHO ARE IN MATHS DEPARTMENT. *TO LIST NAME OF ALL TEACHER WITH THEIR DATE OF ADMISSION IN ASCENDING ORDER. *DISPLAYTEACHERS NAME, SALARY, AGE FOR MALE TEACHER ONLY.

*TO COUNT TNE NUMBER OF TEACHER WITH AGE > 23. *TO INSERT A NEW ROW IN THE TEACHER TABLE WITH THE FOLLOWING DATA : (9,RAJA,26,COMPUTER,13-5-95,23000,M);

SQL>SELECT*FROM TEACHER WHERE DEPARTMENT = HISTORY; SQL>SELECT NAME FROM TEACHER WHERE DEPARTMENT = MATHS AND SEX = F; SQL>SELECT NAME FROM TEACHER ORDER BY D.O.ADM; SQL>SELECT NAME, SALARY, AGE FROM TEACHER WHERE SEX = M; SQL>SELECT COUNT(*) FROM TEACHER WHERE AGE >23; SQL>INSERT INTO TEACHER VALUE (9,RAJA,26,COMPUTER,13-5-95,23000,M);

PROJECT QUESTION NO. 6 Q6. . WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE CLUB. TABLE : CLUB
COACH_ID 1 2 3 4 5 6 7 8 9 10 COACH_NAME KUKREJA RAVINA KARAN TARUN ZUBIN KETAKI ANKITA ZAREEN KUSH SHAILYA AGE 35 34 34 33 36 36 39 37 41 37 SPORTS KARATE KARATE SQUASH BASKETBALL SWIMMING SWIMMING SQUASH KARATE SWIMMING BASKETBALL D.O.APP 27-03-96 20-01-98 19-02-98 01-01-98 12-01-98 24-02-98 20-02-98 22-02-98 13-01-98 19-02-98 PAY 1000 1200 2000 1500 750 800 2200 1100 900 1700 SEX M F M M M F F F M M

*TO SHOW ALL THE INFORMATION ABOUT SWIMMING COACHES IN THE CLUB. *TO LIST NAMES OF ALL COACHES WITH THEIR D.O.ADM IN APP. IN DESCENDING ORDER.

*TO DISPLAY A REPORT, SHOWING COACH_NAME, PAY, AGE AND BONUS (15%OF PAY) FOR ALL THE COACHES. *TO INSERT A NEW ROW IN THE CLUB TABLE WITH THE FOLLOWING DATA: (11,RAJIV,40,HOCKEY,27-05-2000,M);

SQL>SELECT*FROM CLUB WHERE SPORTS = SWIMMING; SQL>SELECT COACH_NAME FROM CLUB ORDER BY D.O.APP DESC; SQL>SELECT COACH_NAME, PAY, AGE, PAY*15 AS BONUS FROM CLUB; SQL>INSERT INTO CLUB VALUE (11,RAJIV,40,HOCKEY,27-05-2000,M);

PROJECT QUESTION NO.7 Q7. WRITE SQL COMMANDS FOR THE FOLLOWING
ON THE BASIS OF GIVEN TABLE GRADUATE. TABLE : GRATUATE
S. NO. 1 2 3 4 5 6 7 8 9 10 NAME KARAN DIVAKAR DIVYA ARUN SABINA JOHN ROBERT RUBINA VIKAS MOHAN STIPEND 400 450 300 350 500 400 250 450 500 300 SUBJECT PHYSICS COMPUTER SC CHEMISRTY PHYSICS MATHS CHEMISTRY PHYSICS MATHS COMPUTER SC MATHS AVERAGE 68 68 62 63 70 55 64 64 62 57 DIV 1 1 2 1 1 2 1 1 1 2

*LIST THE NAMES OF THOSE STUDENTS WHO HAVE OBTAINED DIV = 1 SORTED BY NAME. *DISPLAY THE REPORT, LISTING NAME, STIPEND, SUBJECT AND AMOUNT OF STIPEND RECEIVED INA YEAR ASSUMING THAT THE STIPNED IS PAID EVER MONTH. *TO COUNT THE NUMBER OF STUDENTS WHO ARE EITHER PHYSICS OR COMPUTER SC GRADUATES.

*TO INSERT AN NEW ROW IN THE GRADUATE TABLE: (11,KAJOL,300,COMPUTER SC,75,1);

SQL>SELECT NAME FROM GRADUATE WHERE DIV = 1 AND ORDER BY NAMEL SQL>SELECT NAME, STIPEND, SUBJECT, STIPEND*12 FROM GRADUATES; SQL>SELECT COUNT (*) FROM GRADUATES WHERE SUBJECT = PHYSICS OR COMPUTER SC; SQL>INSERT INTO GRADUATES (11,KAJOL,300,COMPUTER SC,75,1);

PROJECT QUESTION NO.8 Q8. WRITE SQL COMMANDS FOR THE FOLLOWING
ON THE BASIS OF GIVEN TABLE LAB.

TABLE : LAB
S. NO. 1 2 3 4 5 6 7 ITEM NAME COMPUTER PRINTER SCANNER CAMERA HUB UPS PLOTTER COST /ITEM 6 000 15000 18000 21000 8000 5000 25000 QTY. D.O.PURCHASE WARRANTY 9 3 1 2 1 5 2 21-05-96 21-05-97 29-08-98 13-06-98 31-10-99 21-05-96 11-01-00 2 4 3 1 2 1 2 OPERATIONAL 7 2 1 2 1 4 2

*TO SELECT THE ITEM NAME PURCHASE AFTER 3110-97. *TO LIST THE ITEM NAME, WHICH ARE WITHIN THE WARRANTY PERIOD TILL PRESENT DATE. *TO LIST THE ITEM NAME IN ASCENING ORDER OF THE DATE OF PURCHASE WHERE QTY. IS MORE THAN 3.

*TO DISPLAY ITEM NAME, COST PER ITEM AND QTY. WHOSE WARRANTY IS OVER. *TO COUNT THE NUMBER OF ITEMS WHOSE COST IS MORE THAN 10000. *TO INSERT A NEW ROW IN THE LAB TABLE WITH FOLLOWING DATA: (8,VCR,40,10000,2,2-02-00,1,2);

SQL>SELECT ITEM NAME FROM LAB WHERE DATE OF PURCHASE > 30-10-97; SQL>SELECT ITEM NAME FROM LAB WHERE WARRANTY = 1; SQL>SELECT ITEM NAME FROM LAB ORDER BY QTY > 3; SQL>SELECT ITEM NAME, COST PER ITEM, QUANTITY FROM LAB WHERE QUANTITY = NUL; SQL>SELECT COUNT(*) FROM LAB WHERE COST PER ITEM > 10000;

SQL> INSERT INTO LAB VALUE (8,VCR,40,10000,2,2-02-00,1,2);

PROJECT QUESTION NO.9 Q9. WRITE SQL COMMANDS FOR THE FOLLOWING
ON THE BASIS OF GIVEN TABLE FAMILY TABLE : FAMILY
S. NO. 1 2 3 4 5 6 7 8 NAME MISHRA GUPTA KHAN CHADDHA YADAV JOSHI MAURA RAO FEMALE MEMBER 3 4 6 2 7 3 6 5 MALE MEMBER 2 1 3 2 2 2 3 2 INCOME 7000 50000 8000 25000 20000 14000 5000 10000 OCCUPATION SERVICE BUSINESS MIXED BUSINESS MIXED SERVICE FARMING SERVICE

*TO SELECT ALL THE INFORMATION OF FAMILY WHOSE OCCUPATION IS SERVICE. *TO LIST THE NAME OF FAMILY WHERE FEMALE NUMBER IS MORE THAN 3. *TO LIST ALL NAME OF FAMILY WITH INCOME IN ASCENDING ORDER.

*TO DISPLAY FAMILYS NAME, MALE MEMBERS AND OCCUPATION OF BUSINESS FAMILY. *TO COUNT THE NUMBER OF FAMILIES WHOSE INCOME IS LESS THAN 1000. *TO INSERT A NEW ROW IN THE FAMILY TABLE WITH FOLLOWING DATA: (9,DSOUZA,2,1,15000,SERVICE);

SQL>SELECT*FROM FAMILY WHERE OCCUPATION = SERVICE; SQL>SELECT NAME FROM FAMILY WHERE FEMALE MEMBER > 3; SQL>SELECT NAME, INCOME FROM FAMILY ORDER BY; SQL>SELECT NAME, MALE MEMBER FROM FAMILY WHERE OCCUPATION = BUSINESS;

SQL>SELECT COUNT (*) FROM FAMILY INCOME < 1000; SQL>INSERT INTO FAMILY VALUE (9,DSOUZA,2,1,15000,SERVICE);

PROJECT QUESTION NO.10 Q10. WRITE SQL COMMAND FOR THE FOLLOWING
ON THE BASIS OF GIVEN TABLE TRAIN TABLE : TRAIN
S. NO. 1 2 3 4 5 6 7 TRAI N NO. 50001 50002 50003 50004 50005 50006 50007 NAME ANU SAGAR SAMIR GAURAV KAPIL ANKUR PRIYA CLASS 1 AC-CHAIR AC-1 11 1 11 AC-11 SEAT NO. 11 34 2 23 3 6 1 AGE 16 43 78 17 25 20 11 FARE 700 1300 9000 600 1700 500 1200

*TO DISPLAY THE NAME AND SEAT NO.WHERE CLASS IS 11. *TO DISPLAY TRAIN NO. AND SEAT NO. WHERE THE FARE IS > 1300. *TO DISPLAY LIST OF PASSENGER HAVING NAME STARTING WITH A IN ASCENDING ORDER OF TRAIN NO. *TO DISPLAY THE HIGHEST AMOUNT PAID AS FARE.

*TO DISPLAY THE TRAIN NO. AND THE NUMBER OF PASSENGER OF EACH TRAIN. *TO INSERT A NEW ROW IN THE TRAIN TABLE WITH FOLLOWING DATA: (8,S0002,RAMANLAL,11,2,66,3000);

SQL>SELECT NAME, SEAT NO.FROM TRAIN WHERE CLASS = 11; SQL>SELECT TRAIN NO, AND SEAT NO. FROM TRAIN WHERE FARE > 1300; SQL>SELECT NAME FROM TRAIN WHERE NAME LIKE A% ORDER BY NAME; SQL>SELECT MAX(FARE) FROM TRAIN; SQL>SELECT DISTINCT TRAIN NO. AND NO. FROM TRAIN; SQL>INSERT INTO TARIN VALUE (8,S0002,RAMANLAL,11,2,66,3000);

PROJECT QUESTION NO. 11 Q11. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE SHOP TABLE : SHOP
S. NO. 1 2 3 4 5 6 SHOP NAME S.M. SONS DHAROHAR KRITI ART RIPPLE BISWAS CRYSTA; SALE 250000 500000 300000 380000 456000 29000 AREA WEST SOUTH NORTH NORTH EAST SOUTH COST_% 68.6 81.8 79.8 88.0 92.0 66.7 RATING C A A A A A CITY DELHI MUMBAI KOLKATA MUMBAI DELHI KOLKATA

*TO DISPLAY THE NAME OF ALL SHOPS WHICH ARE IN THE SOUTH. *TO DISPLAY NAME AND COUSTOMER PERCENTAGE OF ALL THE SHOPS HAVING COST_PERCENTAGE > 80. *TO DISPLAY LIST OF ALL THE SHOPS WITH SALE > 300000 IN ASCENDING ORDER OF SHOP_NAME, AND RATING FOR EACH SHOP IN THE TABLE, FOR ONLY THOSE SHOPS WHOSE

SALE IS BETWEEN 350000 AND 400000 (INCLUDING BOTH 35000 AND 400000). *TO DISPLAY THE CITY AND THE NUMBER OF SHOPS IN EACH CITY IN THE TABLE SHOP. *TO INSERT DETAIL OF A NEW SHOP IN THE TABLE SHOP WITH THE FOLLOWING DATA. (7,THE SHOP,55000,SOUTH,90.8,A,AHMDABAD);

SQL>SELECT SHOP_NAME FROM SHOP WHERE AREA = SOUTH; SQL>SELECT SHOP_NAME, COST_PERCENT FROM SHOP WHERE COST_PERCENT > 80; SQL>SELECT*FROM SHOP WHERE SALE > 300000 AND ORDER BY SHOP_NAME ASC; SQL>SELECT SHOP_NAME, AREA, RATING FROM SHOP WHERE SALE BETWEEN 35000 AND 400000; SQL>SELECT CITY, COUNT(*) FROM SHOP GROUP BY CITY; SQL>INSERT INTO SHOP VALUE (7,THE SHOP,55000,SOUTH,90.8,A,AHMDABAD);

PROJECT QUESTION NO. 12 Q12. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE FLIGHT TABLE : FLIGHT
S.NO 1 2 3 4 5 6 7
8

FLIGHT NO. T1412 A3242 T1412 C3120 T1412 C3120 A3242 T1412 T1618

FROM CITY BLUE ISLAND PIKSWA PERIMILA KETTY ISLAND JASWAKA PIKSWAKA HARAPAN ISLAND BLUE ISLAND MUMSUI

TO CITY YOYO TOWN YOYO TOWN YOYO TOWN BLUE ISLAND PERMILA ARCHIC LAND KETTY ISLAND HARAPAN VALLEY BLUE ISLAND

DISTANCE 1500 900 1000 1200 500 1000 900 1200 1200

SEATS 210 170 210 120 120 170 210 120 210

FREQUENCY 3 7 7 7 4 4 1 2 4

*TO DISPLAY THE FLIGHT NO.OF THOSE FLIGHT WHICH HAVE FREQUENCY MORE THAN 4 TIMES IN A WEEK. *DISPLAY FLIGHT NO.FROM CITY AND TO CITY OF ALL THOSE FLIGHT WHICH ARE STARTING FROM CITY BLUE ISLAND OR ARE HAVING DESTINATION AS BLUE ISLANDS.

*TO DISPLAY FLIGHT NO. FREQUENCY AND DISTANCE OF ALL THOSE FLIGHTS, WHICH ARE COVERING DISTANCE MORE THAN 900 KILOMETERS. *TO DISPLAY FLIGHT NO.AND SEATING CAPACITY OF ALL THE THOSE FLIGHT IN WHICH SEATING CAPACITY IS MORE THAN 140. *TO DISPLAY FLIGHT NO. OF ALL THOSE FLIGHTS WHICH ARE WEEKLY FLIGHTS AND HAVING SEATING CAPACITY LESS THAN 180. *TO INSERT A NEW ROW IN THE FLIGHT TABLE WITH FOLLOWING DATA. (9,T1618,MUMSUI,BLUE ISLAND,1200,210,4);

SQL>SELECT FLIGHT NO. FROM FLIGHT WHERE FREQUENCY > 4; SQL>SELECT FLIGHT NO. FROM CITY FROM FLIGHT WHERE FROM CITY = BLUE ISLAND OR TO CITY = BLUE CITY; SQL>SELECT FLIGHT NO., SEAT FROM FLIGHT WHERE SEATS > 140; SQL>SELECT FLIGHT NO., FREQUENCY, DISTANCE FROM FLIGHT WHERE DISTANCE > 900; SQL>SELECT FLIGHT NO. FROM FLIGHT WHERE FREQUENCY = 1 AND SEAT < 180; SQL>INSERT INTO VLUE (9,T1618,MUMSUI,BLUE ISLAND,1200,210,4);

PROJECT QUESTION NO.13 Q13. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE LIBRARY TABL7E : LIBRARY
S.NO 1 2 3 4 5 6 7 8
9

10

TITILE DATA STUCTURE DOS GUIDE TURBOO C++ DBASE DUMIES MAST.WINDOW COMP.STUDIES COBOL GUIDE NETWOK BACE FOR BEGINNNERS ADV. PASCAL

AUTHOR LIPSSCHUTE NORTON ROBOT LAFORE PALMER COWART FRENCH STERN FREED NORTON SCHILTD

SUBJECT DS OS PROG DBMS OS FDN PROG NET PROG PROG

PUBLISHER MC GRAW PHI GALGOTIA PUSTAK M BPB GALGOTIA JOHN W ZPRESS BPB MCGRAW

QTY 4 3 5 7 1 2 4 3 3 4

PRICE 217 175 270 130 225 75 10000 200 40 350

*TO DISPLAY THE TITLE OF ALL THE BOOKS WITH PRICE BETWEEN 100 AND 300. *TO DISPLAY TITLE AND AUTHOR OF ALL THE BOOKS HAVING TYPE PROG AND PUBLISHER BY BPB.

*TO DISPLAY LIST OF ALL THE BOOKS WITH THE PRICE MORE THAN 130 IN ASCENDING ORDER OF QTY. *TO DISPLAY A REPORT WITH TITLE, MAISPLACEMENT CHARGES FOR EACH BOOK IN THE TABLE. *TO DISPLAY THE PUBLISHER AND THE NUMBER OF BOOKS OF EACH PUBLISHER IN THE TABLE LIBRARY. TO INSERT A NEW ROW IN THE TABLE LIBRARY WITH THE FOLLOWING DATA (11,COMPUTER SC.C++,RITA,KHANNA,1225);

SQL>SELECT TITLE FROM LABRARY WHERE PRICE BETWEEN 100 AND 300; SQL>SELECT TITLE, AUTHOR FROM LIBRARY WHERE SUBJECT = PROG AND PUBLISHER = BPB; SQL>SELECT TITLE FROM LIBRARY WHERE PRICE > 130 AND ORDER BY QTY; SQL>SELECT TITLE, PRICE*1.5 AS MISPLACEMENT CHARGES FROM LIBRARY; MYDQL>SELECT DISTINCT PUBLISHER, COUNT(*) FROM LIBRARY GROUP BY PUBLISHER; SQL>INSERT INTO LIBRARY VALUE (11,COMPUTER SC.C++,RITA,KHANNA,1225);

PROJECT QUESTION NO.14 Q14. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE BANK TABLE : BANK
ACC_NO. 1 2 3 4 5 6
7 8

CNAME KARAN PUNEET ANIRBAN YATIN SUNNY JAYANT NIKHIL TARUN JISHA

BNAME B. OF BARODA SATE BANK ORIENTAL B. STND. CHAR. STATE BANK UCO BANK B. OF BARODA ORIENTAL B. UCO BANK

AMOUNT 15000 2500 17000 38000 47000 34000 56000 22000 34500

D.O.OPEN 12-01-98 01-02-97 15-07-99 10-02-99 06-02-98 10-08-98 02-02-99 04-04-99 05-01-98

T_TRANSACTION 10 09 05 11 15 07 12 08 11

*DISPLAY DATA FOR ALL CUSTOMER WHOSE TRANSACTION IS BETWEEN 8 AND 11. *DISPLAY DATA FOR ALL CUSTOMER SORTED BY THEIR D.O.OPEN. *TO COUNT THE NUMBER OF CUSTOMER WITH AMOUNT < 30000. *LIST THE MINIMUM AND MAXIMUM AMOUNT FROM THE BANK.

*TO LIST CNAME, BNAME, AMOUNT FOR ALL THE CLIENTS WHOSE AMOUNT IS < 20000. *TO DISPLAY ACC_NO., CNAME, BNAME, TOTAL TRANSACTION IN DESCENDING ORDER OF AMOUNT.

SQL>SELECT*FROM BANK WHERE T_TRANSACTION BETWEEN 8 AND 11; SQL>SELECT*FROM BANK ORDER BY D.O.OPEN; SQL>SELECT COUNT (*) FROM BANK WHERE AMOUNT < 30000; SQL>SELECT MIN (AMOUNT) FROM BANK; SQL>SELECT CNAME, BNAME, AMOUNT FROM BANK WHERE AMOUNT < 20000; SQL>SELECT ACC_NO., BNAME, AMOUNT, T_TRANSACTION FROM BANK ORDER BY AMOUNT DESC;

PROJECT QUESTION NO.15 Q15. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE VOTER TABLE : VOTER
V. NO 1 2 3 4 5 6 7
8

9 10

V. NAME DIVAKAR RAJIV SMITH ARPIT SUNNY SUNIL RAJIV ROHIT VIDHI ANAND

AGE 22 23 24 19 26 23 27 24 34 26

ADDRESS ROHINI SAROJINI NAGAR SAROJINI NAGAR PASCHIM VIHAR DEV NAGAR VIKAS PURI ROHINI ROHINI PITAM PURA BANK VIHAR

PHONE 27045249 25567892 25456697 25457878 25487304 25478784 25146365 25146987 25445656 25466566

*TO LIST V.NO., V. NAME, AGE FOR ALL THE VOTERS. THIS INFORMATION SHOULD BE SORTED ON V. NAME. *TO LIST ALL THOSE VOTERS WHO ARE EITHER RESIDING IN ROHINI OR WHOSE AGE < 25. *DISPLAY ALL THE VOTER WITH AGE > 27. *LIST DIFFERENT VOTERS WITH UNIQUE AGE.

*COUNT THE NUMBER OF VOTER OF VOTERS WHER ADDRESS IS ROHINI. *INSERT A NEW ROW IN THE VOTER TABLE. FILL THE ENTIRE COLUMN WITH VALUES (11,VAIBHAV,18,PASCHIM VIHAR,25255186);

SQL>SELECT V. NO, AGE FROM VOTERS ORDER BY V.NAME; SQL>SELECT*FROM VOTERS WHERE ADDRESS=ROHINI OR AGE > 27; SQL>SELECT DISTINCT AGE FROM VOTERS; SQL>SELECT COUNT (*) FROM VOTERS WHERE ADDRESS = ROHINI; SQL>INSERT VOTER VALUE (11,VAIBHAV,18,PASCHIM VIHAR,25255186);

PROJECT QUESTION NO.16 Q16. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE DIRECTORY TABLE : DIRECTORY
S. NO. 1 2 3 4 5 6
7

FNAME ARPIT RAM VIKAS ROHIT KISAN RAHUL RAKESH PARUL

LNAME THUKRAL SHARMA MALHOTRA ARORA KAUSHIK VERMA GULATI ARORA

PHONE 43590465 27894563 27123200 27541552 27456566 27889443 27141145 27136464

ADDRESS PASCHIM VIHAR VIKAS PURI PITAM PURA PREET VIHAR ROHINI ROHINI PITAN PURA ROHINI

*TO SELECT ALL THE INFORMATION FROM DIRECTORY OF ROHINI AREA. *UPDATE THE DATABASE SET THE PHONE NO. AS 27047645 WHERE PHONE NO. IS 27123200. *TO CREAT A VIEW CALLED DIRECTORY WITH THE FOLLOWING FIELDS FNAME, PHONE, ADDRESS. *TO DISPLAY THE DATA FOR ARPIT, RAHUL, KISAN.

*TO DELETE THE ROW WHERE THE ADDRESS IS ROHINI. *TO DELETE THE DATA PHYSICALLY.

SQL>SELECT* FROM DIRECTORY WHERE ADDRESS = ROHINI; SQL>UPDATE DIRECTORY SET PHONE = 27047645 WHERE PHONE = 27123200; SQL>INSERT INTO DIRECTORY VALUE (FNAME VARCHAR(30), PHONE INTEGER, ADDRESS VARCHAR(30)); SQL>SELECT* FROM DIRECTORY WHERE FNAME = ARPIT AND RAHUL AND KISAN; SQL>ALTER TABLE DIRECTORY DROP ADDRESS = ROHINI; SQL>DROP TABLE DIRECTORY;

PROJECT QUESTION NO.17 Q17. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE MOVIE TABLE : MOVIE
S.NO. 1 2 3 4 5 6 7 8 9 10 TITLE GONE WITH WIND FRIDAY THE 13TH TOP GUNS SPLASH INDEPENDENCE DAY RISKY BUSINESS CANOON CROCODILE DUNDEE 101 DALMATIANS TOOTSIE TYPE DRAMA HORROR DRAMA COMEDY DRAMA COMEDY SCIFI COMEDY COMEDY COMEDY RATING G R PG PG 13 R R PG PG 13 G PG STARS GABLE JASON CRUISE HANKS TURNER CRUISE AMECHE HARIS HOFFMAN HOFFMAN QTY 4 2 7 3 3 2 2 2 3 1 PRICE 39.95 69.95 49.95 29.95 19.95 44.95 31.95 69.95 59.95 29.95

*FIND THE TOTAL VALUE OF THE MOVIE CASSETTES AVAILABLE IN THE LIBERARY. *DIPLAY A LIST OF ALL THE MOVIE WITH THE PRICE OVER 20 AND SORTED BY PRICE. *DIPLAY ALL THE MOVIE SORTED BY QTY. IN DESCENDING ORDER.

*DIPLAY A REPORT LISTING A MOVIE NUMBER, CURRENT VALUE AND REPLACEMENT VALUE FOR EACH MOVIE IN THE ABOVE TABLE. CALCULATE THE REPLACEMENT VALUE FOR ALL THE MOVIES AS QTY*PRICE*1.15. *COUNT THE NUMBER OF MOVIE WHERE RATING IS NOT G. *INSERT A NEW ROW IN THE MOVIE TABLE FILL ENTIRE COLUMN WITH VALUE (11,FIMALDESTINATION,MYSTREOUS,AE,DANIEL ,4,99.00);

SQL>SELECT COUNT(*)FROM MOVIE. SQL>SELECT TITLE FROM MOVIE WHERE PRICE > 20 AND ORDER BY PRICE; SQL>SELECT TITLE FROM MOVIE ORDER BY DESC; SQL>SELECT NO. TITLE FROM MOVIE WHERE QTY*PRICE*1.15;

SQL>SELECT COUNT(*) FROM MOVIE WHERE RATING = G; SQL>INSERT INTO MOVIE VALUE (11,FIMALDESTINATION,MYSTREOUS,AE,DANIEL ,4,99.00);

PROJECT QUESTION NO.18 Q18. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE PRODUCT. TABLE : PRODUCT
S. NO. 1 2 3 4 5 6 7 8 NAME MOTHER BOARD KEYBOARD MOUSE SOUND CARD SPEAKER MONITOR CD-ROM PRINTER PRICE 7000 1000 500 600 600 3000 2800 79000 SUPPLIER INTEL TVSE LOGITECH SAMSUNG SAMSUNG PHILIPS CREATIVE HP STOCK 20 70 60 50 25 22 32 10

*TO DISPLAY DATA FOR THE ENTIRE ITEM SORTED BY THEIR NAME. *TO DISPLAY THE NAME AND PRICE FROM THE TABLE ITEM IN DESCENDING ORDER OF THEIR STOCK. *LIST ALL THE NAMES AND PRICE WITH PRICE BETWEEN 3000 AND 7000.

*WRITE A SQL COMMAND TO DELETE ROWS WITH STOCK BETWEEN 20 TO 40. *TO COUNT THE NUMBER OF PRODUCTS WITH THE STOCK < 5.

SQL>SELECT*FROM PRODUCT ORDER BY NAME; SQL>SELECT NAME, PRICE FROM PRODUCT ORDER BY STOCK DESC; MYDQL>SELECT NAME, PRICE FROM PRODUCT WHERE PRICE BETWEEN 3000 AND 7000. SQL>DELETE FROM PRODUCT WHERE STOCK BETWEEN 20 OR 40; SQL>SELETC COUNT (*) FROM PRODUCT WHERE STOCK < 5;

PROJECT QUESTION NO.19 Q19. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE EMP_SALARY. TABLE : EMP_SALARY
EMP_ID 010 105 152 215 244 300 335
400

441

FNAME GEORGE MARY SAM SARAH MANILA RABERT HENRY RACHEL PETER

LNAME SMITH JONES TONES ACKER SEN SAMUEL WILLIAM LEE THOMAS

COUNTRY US UK FRANCE US USA US US UK FRANCE

SALARY 75000 65000 80000 75000 50000 45000 40000 32000 28000

BENEFITS 15000 15000 25000 12500 12000 10000 10000 7500 7500

DESIGNATION MANAGER MANAGER DIRECTOR NAMAGER CLERK CLERK CLERK SALESMAN SALESMAN

*TO DISPLAY FNAME, LNAME, COUNTRY AND SALARY OF ALL THE EMPLOYEES LIVING IN US FROM THE TABLE EMP_SALARY. *TO DISPLAY THE CONTENTS OF EMP_SALARY TABLE IN DESCENDING ORDER OF FNAME. *TO DISPLAY THE FNAME, LNAME, SALARY ALL THE MANAGER FROM THE TABLE.

*TO DISPLAY THE MAXIMUM SALARY AMONG MANAGER AND CLERK FROM THE TABLE. *TO DELETE THE TABLE PHYSICALLY.

SQL>SELECT FNAME, LNAME, COUNTRY, SALARY FROM EMP_SALARY WHERE COUNTRY = US; SQL>SELECT * FROM EMP_SALARY ORDER BY FNAME DESC; SQL>SELECT FNAME, LNAME, SALARY FROM EMP_SALARY WHERE DESIGNATION = MANAGER; SQL>SELECT MAX SALARY FROM EMP_SALARY DESIGNATION = MANAGER OR CLERK; SQL>DROP TABLE EMP_SALARY;

PROJECT QUESTION NO.20 Q20. WRITE SQL COMMANDS FOR THE


FOLLOWING ON THE BASIS OF GIVEN TABLE FURNITURE. TABLE : FURNITURE
S. NO. 1 2 3 4 5 6 7 8 9 10 ITEM NAME WHITE LOTUS PINK FEATURE DOLPHIN DECENT COMFORT ZONE DONALD ROYAL FINISH ROYAL TIGER ECONO SETTING EATING PARADISE TYPE DOUBLE BED BABY COT BABY COT OFFICE TABLE DOUBLE BED BABY COT OFFICE TABLE SOFA SOFA DINNING TABLE D.O.STOCK 23-03-2002 20-01-2002 29-02-2002 02-01-2002 12-02-2002 23-03-2002 24-03-2002 24-02-2002 28-01-2002 1-02-2002 PRICE 30000 7000 9500 25000 25000 6500 18000 31000 95-11500 DISCOUNT 25 25 20 30 23 15 30 30 25 25

*TO SHOW ALL THE INFORMATION ABOUT THE BABY COTS FROM THE FURNITURE TABLE. *TP LIST THE ITEM NAME WHICH ARE PRICED AT MORE THAN 15000 FROM THE FURNITURE TABLE. *TO LIST ITEM NAME AND TYPE OF THOSE ITEM, IN WHICH DATE OF STOCK IS BEFORE 01-02-2002

FROM THE FURNITURE TABLE IN DESCENDING ORDER OF ITEM NAME. *TO DISPLAY ITEM NAME AND DATE OF STOCK OF THOSE ITEMS, IN WHICH THE DISCOUNT PRECENTAGE IS MORE THAN 25 FROM FURNITURE TABLE. *TO COUNT THE NUMBER OF ITEMS, WHOSE TYPE IS SOFA FROM FURNITURE TABLE.

SQL>SELECT*FROM FURNITURE WHERE TYPE = BABY COT; SQL>SELECT ITEM NAME FROM FURNITURE WHERE PRICE > 15000; SQL>SELECT ITEM NAME, TYPE FROM FURNITURE WHERE D.O.STOCK < 01-02-2002 ORDER BY ITEM NAME DESC; SQL>SELECT ITEM NAME, D.O.STOCK FROM FURNITURE WHERE DISCOUNT > 25;

SQL>SELECT COUNT (*) FROM FURNITURE WHERE TYPE = SOFA;

PROJECT QUESTION NO.21 Q21. WRITE SQL COMMAND FOR THE FOLLOWING
ON TH BASIS OF GIVEN TABLE BOOKS TABLE : BOOKS
BOOK ID 1 2 3 4 5 BOO K NAME FAST COOK THE TEARS MY FIRST C++ C++ BRAINWRKS THUNDERBOLTS AUTHOR NAME LATA KAPOOR WILLIAM SMITH BRAIN & BROOKE A.W. ROSSAINE ANNA ROBERT PUBLISHER EPB FIRST PUBL. EPB TDH FIRST PUBL. PRICE 355 650 350 350 750 TYPE COOKERY FICTION TEXT TEXT FICTION QTY. 5 20 10 15 50

*TO SHOW BOOK NAME, AUTHOR NAME AND PRICE OF BOOKS OF FIRST PUBL. PUBLISHER. *TO LIST ALL THE NAME FROM BOOKS OF TEXT TYPE. *TO DISPLAY THE NAMES AND PRICE FROM BOOKS IN ASCENDING ORDER OF THEIR PRICE. *TO INCREASE THEIR PRICE OF ALL THE BOOKS OF EPB PUBLISHER BY 50.

SQL>SELECT BOOK NAME, AUTHOR NAME, PRICE FROM BOOKS WHERE PUBLISHER = FIRST PUBL; SQL>SELECT BOOK NAME FROM BOOKS WHERE TYPE = TEXT; SQL>SELECT BOOK NAME, PRICE FROM BOOKS ORDER BY PRICE ASC; SQL>UPDATE BOOKS SET PRICE WHERE PUBLISHER = EPB AND PRICE = PRICE+50;

PROJECT QUESTION NO.22 Q22. WRITE SQL COMMAND FOR THE FOLLOWING
ON TH BASIS OF GIVEN TABLE GARMENTS TABLE : GARMENTS
G.CODE 10023 10001 10012 10024 10090 10019 10009 10007 10020 10089 DESCRIPTION PENCIL SKIRT FROMAL SHIRT INFORMAL SHIRT BABY COT TULIP SKIRT EVENING GOWN INFORMAL PANTS FORMAL PANTS FROCK SLACKS PRICE 1150 1250 1550 750 850 850 1500 1350 850 750 F.CODE F03 F01 F02 F03 F02 F03 F02 F01 F04 F03 READY DATE 19-02-2008 12-01-2008 06-01-2008 07-04-2007 31-03-2007 06-01-2008 20-10-2008 09-03-2008 09-09-2007 20-10-2007

*TO DISPLAY G.CODE AND DESCRIPTION OF EACH GARMENT IN DESCINDING ORDER OF G.CODE. *TO DISPLAY THE DETAILS OF ALL THE GARMENTS, WHICH HAVE READY DATE IN BETWEEN 08-12-2008 AND 16-06-2008. *TO DISPLAY THE AVERAGE PRICE OF ALL THE GARMENTS, WHICH ARE MADE UP OF FABRIC WITH F.CODE AS F03.

*TO DISPLAY FABRIC WISE HIGHEST AND LOWEST PRICE OF GARMENTS FROM GARMENTS TABLE. (DISPLAY F.CODE OF EACH GARMENT ALONG WITH HIGHEST AND LOWEST PRICE.)

SQL>SELECT DISTINCT G.CODE, DESCRIPTION FROM GARMENT ORDER BY G. CODE DESC; SQL>SELECT * FROM GARMENT WHERE READY DATE BETWEEN 08-12-1007 AND 16-06-2008; SQL>SELECT AVG PRICE FROM GARMENT WHERE FCODE = F03; SQL>SELECT MAX FCODE FROM GARMENT ORDER BY PRICE;

PROJECT QUESTION NO.23 Q23. WRITE SQL COMMAND FOR THE FOLLOWING
ON TH BASIS OF GIVEN TABLE STORE. TABLE : STORE
ITEM NO. 2005 2003 2002 2006 2001 2004 2009 ITEM SHARPENER CLASSIC BALL PEN NO.25 GEL PEN PREMIUM GEL PEN CLASSIC ERASER SMALL ERASER BIG BALL PEN 0.5 SCODE 23 22 21 21 22 22 21 QTY 60 50 150 250 220 110 180 RATE 6 25 12 20 6 8 18 LAST BUY 31-06-2009 01-02-2010 24-02-2010 11-03-2009 19-01-2009 02-12-1009 03-11-2009

*TO DISPLAY DETAILS OF ALL THE ITEMS IN THE STORETABLE IN ASCENDING ORDER OF LAST BUY. *TO DISPLAY ITEM NO.AND ITEM NAME OF ALL THOSE ITEMS FROM STORE TABLE WHOSE RATE IS MORE THAN 15 RUPEES. *TO DISPLAY THE DETAILS OF THOSE ITEMS WHOSE SUPPLIER CODE (SCODE) IS 22 OR QTY IN STORE (QTY) IS MORE THAN 110 FROM THE TABLE STORE.

*TO DISPLAY MINIMUM RATE OF ITEMS FOR EACH SUPPLIER INDIVIDUALLY AS PER SCODE FROM THE TABLE STORE.

SQL>SELECT * FROM STORE ORDER BY LAST BUY; SQL>SELECT ITEM NO., ITEM NAME FROM STORE WHERE RATE > 15; SQL>SELECT * FROM STORE WHERE SCODE = 22 AND QTY > 110; SQL>SELECT DISTINCT MIN RATE FROM STORE ORDER BY SCODE;

PROJECT QUESTION NO.24

Q24. WRITE SQL COMMAND FOR THE FOLLOWING


ON TH BASIS OF GIVEN TABLE DRESS TABLE : DRESS
DCODE 10001 10020 10012 10019 10090 10023 10089 10007 10009 10024 DESCRIPTION FORMAL SHIRT FROCK INFORMAL SHIRT EVENING GOWN TULIP SKIRT PENCIL SKIRT SLACKS FORMAL PANT IMFORMAL PANTS BABY TOP PRICE 1250 750 1450 850 850 1250 850 1450 14050 650 MCODE M001 M004 M002 M003 M002 M003 M003 M001 M002 M003 LAUNCH DATE 2008-01-12 2007-09-09 2008-06-06 2007-06-06 2008-03-31 2008-12-19 2008-10-20 2008-03-09 2008-10-20 2007-04-07

*TO DISPLAY DCODE AND DESCRIPTION OF EACH DRESS IN DESCENDING ORDER OF CODE. *TO DISPLAY THE DETAILS OF ALL THE DRESS WHICH HAVE LAUNCH DATE IN BETWEEN 2007-1205 AND 2008-06-08. *TO DISPLAY THE AVERAGE PRICE OF ALL THE DRESS WHICH ARE MADE UP OF MATERIAL WITH MCODE AS M003.

*TO DISPLAY MATERIAL WISE HIGHEST AND LOWEST PRICE OF DRESS FROM DRESS TABLE.

SQL>SELECT DCODE, DESCCRIPTION FROM DRESS ORDER BY DCODE DECS; SQL>SELECT*FROM DRESS WHERE LAUNCH DATE BETWEEN 2007-12-05 AND 2008-06-08; SQL>SELECT AVG PRICE FROM DRESS WHERE MCODE = M003; SQL>SELECT MAX PRICE, MIN PRICE FROM DRESS;

PROJECT QUESTION NO. 25 Q25. WRITE SQL COMMAND FOR THE FOLLOWING
ON THE BASIS OF GIVEN TABLE COACHING. TABLE : COACHING

NAME RAHUL SHALU ABHA SUMAN KULKARNI ROHIT

AGE 24 21 23 25 22 25

DEPARTMENT HINDI COMPUTER HISTORY HISTORY COMPUTER HINDI

D.O.ADM 2009-01-10 2008-03-24 2010-12-09 2001-09-09 2002-05-18 2009-15-17

FEE 2000 1200 3000 2500 4000 3500

SEX M F F F M M

*TO SHOW THE INFORMATION ABOUT THE STUDENT OF COMPUTER DEPARTMENT. *TO LIST NAMES OF MALE STUDENT WHO ARE IN HINDI DEPARTMENT. *TO LIST THE NAMES OF ALL THE STUDENT IN ASCENDING ORDER OF THEIR AGE. *TO DISPLAY AGE, FEE OF FEMALE STUDENT WHO PAY MORE THAN 350. *TO DISPLAY ALL THE NAMES THAT END WITH NI. *TO DISPLAY THE DISTINCT DEPARTMENT. SQL>SELECT * FROM COACHING WHERE DEPARTMENT = COMPUTER; SQL>SELECT NAME FROM COACHING WHERE SEX = M AND DEPARTMENT = HINDI;

SQL>SELECT NAME FROM COACHING ORDER BY AGE ASC; SQL>SELECT AGE, FEE FROM COACHING WHERE SEX = F AND FEE > 350; SQL>SELECT NAME FROM COACHING WHERE NAME LIKE NI%; SQL>SELECT COUNT (*) FROM COACHING WHERE AGE > 22; SQL> SELECT DISTINCT DEPARTMENT FROM COACHING;

Related Interests