You are on page 1of 4

SQL:

Write the SQL queries for (i) to (iv) and find the output for SQL queries (v) to (viii),which are based
on the tables.
Table :BOOK
CODE BNAME TYPE
F101 The priest Fiction
L102 German easy Literature
C101 Tarzan in the lost world Comic
F102 Untold story Fiction
C102 War heroes Comic

TABLE :MEMBER
MNO MNAME CODE ISSUEDATE
M101 RAGHAV SINHA L102 2016-10-13
M103 SARTHAK JOHN F102 2017-02-23
M102 ANISHA KHAN C101 2016-07-12
i. To display all details from table MEMBER in descending order of ISSUEDATE
ii. To display the bno and bname of all fiction type books from the table BOOK
iii. To display TYPE and number of books in each type from the table BOOK
iv. To display all MNAME and ISSUEDATE of those members from table member who have book
issued in the year 2017
v. SELECT MAX(ISSUEDATE) FROM MEMBER;
vi. SELECT DISTINCT TYPE FROM BOOK;
vii. SELECT A.CODE,BNAME,MNO,MNAME FROM BOOK A,MEMBER B WHERE A.CODE=B.CODE;
viii. SELECT BNAME FROM BOOK WHERE TYPE NOT IN (“FICTION”,”COMIC”);

Write the SQL queries for (i) to (iv) and find the output for SQL queries (v) to (viii),which are based
on the tables
TABLE:DEPT
DCODE DEPARTMENT CITY
D101 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
DO4 INFRASTRUCTURE MUMBAI

TABLE :WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George k 2013-09-02 1991-09-01 male D01
1002 Ryma sen 2012-12-11 1990-12-15 female D03
1003 Mohitesh 2013-02-03 1987-09-04 Male D05
1007 Anil jha 2014-01-17 1984-10-19 Male D04
1004 Manila sahai 2012-12-09 1986-11-14 female D01
1005 R sahay 2013-11-18 1987-03-31 male D02
1006 Jaya priya 2014-06-09 1985-06-23 female D05

Doj refers to date of joining


Dob refers to date of birth

I. To display Wno,Name,Gender from the table WORKER in descending order of wno.


II. To display the name of all the female worker from the table WORKER.
III. To display the Wno and Name of those workers from the table WORKER who are born
between ‘1987-01-01’ and ‘1991-12-01’.
IV. To count and display male workers who have joined after after ‘1988-01-01’.
V. SELECT COUNT(*) ,DCODE FROM WORKER GROUP BY DCODE HAVING COUNT(*)>1;
VI. SELECT DISTINCT DEPARTMENT FROM DEPT;
VII. SELECT NAME,DEPARTMENT,CITY FROM WORKER W,DEPT D WHERE W.DCODE=D.DCODE
AND WNO<1003;
VIII. SELECT MAX(DOJ),MIN(DOB) FROM WORKER;

Write the SQL queries for (i) to (iv) and find the output for SQL queries (v) to (viii),which are based
on the tables
TABLE :BOOKS
Book_Id Book_Name Author_Name Publishers Price Type Qty
C0001 Fast Cook Lata kapoor EPB 355 COOKERY 5
F0001 The Tears William hopkins FIRST PUBL. 650 FICTION 20
T0001 My First C++ Brain & brooke EPB 350 TEXT 10
T0002 C++ brainworks A.w.rossaine TDH 350 TEXT 15
F0002 Thunderbolts Anna reborts F.IRST PUBL 750 FICTION 50
TABLE: ISSUED
Book_Id Quantity_Issued
T0001 4
C0001 3
F0001 2
i. To show Book_Name,Author name and price of books of First Publ.publishers.
ii. To list the names from books of text type.
iii. To display the names and price from books in ascending order of their price.
iv. To increase the price of all book of epb publishers by 50
v. SELECT COUNT(*) FROM BOOKS;
vi. SELECT MAX(PRICE) FROM BOOKS WHERE QTY>=15
vii. SELECT BOOK_NAME,AUTHOR_NAME FROM BOOKS WHERE PUBLISHERS=’EPB’;
viii. SELECT COUNT(DISTINCT PUBLISHERS) FROM BOOKS WHERE PRICE >=400;

Write the SQL queries for (i) to (iv) and find the output for SQL queries (v) to (viii),which are based
on the tables.
Table: EMPLOYEE

ECODE NAME DESIGN SGRADE DOJ DOB


101 ABDM SENUL AHMAD EXECUTIVE S03 23-MAR-2003 13-JAN-1980
102 RAVI CHANDER HEAD_IT S02 12-FEB-2010 22-JUL-1987
103 JOHN KEN RECEPTIONIST S03 24-JUN-2009 24-FEB-1983
105 NAZAR AMEN GM S02 11-AUG-2006 03-MAR-1984
108 PRIY CEO S01 29-DEC-2004 109-JAN-1982

Table: SALGRADE

SGRADE SALARY HRA


S01 56000 18000
S02 32000 12000
S03 24000 8000
i. To display the details of all employees in descending order of DOJ
ii. To display name and design of those employees, whose SGRADE is either S02 or S03
iii. To display the content of the employee table, whose doj is in between ’09-FEB-2000’ and
’08-AUG-2009’
iv. To count the number of employees based on SGRADE.
v. SELECT * FROM EMPLOYEE ORDER BY DOJ DESC;
vi. SELECT MIN (DOB),MAX(DOJ) FROM EMPLOYEE;
vii. SELECT NAME, DESIGN FROM EMPLOYEE E ,SALGRADE S WHERE E.SGRADE=S.SGRADE AND
E.ECODE<103;
viii. SELECT SGRADE,SALARY+HRA FROM SALGRADE WHERE SGRADE=’S02’;

Write the SQL queries for (i) to (iv) and find the output for SQL queries (v) to (viii),which are based
on the tables.
Table :DVD
CODE DTITLE DTYPE
F101 Henry Martin Folk
C102 Dhurpad Classical
C101 The Planets Classical
F102 Universal Soldier Folk
R102 A Day in life Rock

TABLE :MEMBER
MNO MNAME CODE ISSUEDATE
101 AGM SINGH R102 2017-11-30
103 ARTH JOSEPH F102 2016-12-13
102 NISHA HANS C101 2017-07-24

i. To display all details from table MEMBER in descending order of ISSUEDATE


ii. To display the DCODE and DTITLE of all folk type DVDs from the table DVD.
iii. To display the DTYPE and number of DVDs in each DTYPE from the table DVD
iv. To display all name and ISSUEDATE of those members from table MEMBER
v. SELECT MIN(ISSUEDATE) FROM MEMBER;
vi. SELECT DISCTINT DTYPE FROM DVD;
vii. SELECT D.CODE,NAME,DTITLE FROM DVD D,MEMBER M WHERE D.CODE=M.CODE;
viii. SELECT DTITLE FROM DVD WHERE DTYPE NOT IN (“FOLK”,”CLASSICAL”);

List of C++ programs

1. Write a C++ program to implement Student Result Analysis System using class
2. Write a C++ program to implement Function overloading without using class
3. Write a C++ program to implement the multiple inheritance
4. Write a C++ program to implement the multilevel inheritance
5. Write a C++ file program to count lines, characters, particular word in a text file.
6. Write a C++ program to perform binary file manipulation (insertion and display)
7. Write a C++ program to perform binary file manipulation (delete and display)
8. Write a C++ program to perform binary file manipulation (search and display)
9. Write a C++ program to search a element using linear and binary search method
10. Write a C++ program to implement dynamic stack (linked list implementation)
11. Write a C++ program to implement dynamic queue (linked list implementation)

You might also like