You are on page 1of 10

RELATION: EMPLOYEE

Empno 7839 7849 7859 7869 7679 7889 7899 7900 7901

Name King Blake Jones Martin Allen Smith James Adam Miller

Job Manager Salesman Salesman Manager Clerk Analyst Salesman Clerk Clerk

Mgr 7639 7689 7689 7639 7699 7679 7689 7699 7699

Hiredate 01/11/91 12/12/81 24-05-81 25-06-92 19-07-81 31-12-81 05/05/92 06/06/93 07/07/94

Salary 5000 2500 2450 5000 2350 4000 2250 1550 1770

Dept no 10 30 10 30 10 15 15 30 15

1. Find all the employee whose job does not start with 'M' SELECT* FROM EMPLOYEE WHERE job NOT LIKE M%; 2. List min salary of each job type SELECT MIN (SAL) FROM EMPLOYEE GROUP BY job; 3. Find the no. of employee having manager as job SELECT COUNT (Empno) FROM EMPLOYEE GROUP BY JOB HAVING JOB ='manager'; 4. To display all the employees who were hired during 81 SELECT* FROM EMPlOYEE WHERE HIREDATE LIKE '%-%-81' ;

5. Give the output

- SELECT MIN(SALARY) from EMPLOYEE; MIN (SALARY) 1550 - SELECT COUNT (DISTINCT DEPT NO) FROM EMPLOYEE; COUNT (DISTINCT DEPT NO) 3 - SELECT COUNT (DISTINCT JOB) FROM EMPLOYEE; COUNT (DISTINCT JOB) 4 - SELECT SUM (SALARY) FROM EMPLOYEE; SUM(SALARY) 26870

RELATION: SUPPLIER
Code 7839 7849 7859 7869 7879 7889 Name King Blake Jones Martin Allen Smith City Delhi Bangalore Delhi Bombay Madras Delhi Itemno 1000 1009 1007 1002 1001 1005 Suppliedqty 100 200 150 190 20 300 Rate 40 30 40 20 50 40

1. Display name of suppliers whose names start with letter 'K' SELECT NAME FROM supplier Where Name LIKE K%; 2. Display details of suppliers residing in Delhi SELECT * FROM supplier WHERE city= DELHI; 3. Display supplier name. Item no. & supplied qty for the qty<150 SELECT name, itemno, suppliedqty FROM supplier WHERE suppliedqty<150; 4. To inseert a new row in the supplier INSERT INTO supplier VALUES (7899, ROY, MADRAS, 1005, 300, 50); 5. Give the output: -SELECT MIN (rate) from supplier; MIN (rate) 20 -SELECT MAX (rate) from supplier; MAX (rate) 50 -SELECT COUNT (DISTINCT CITY) FROM SUPPLIER; COUNT (DISTINCT CITY) 4

RELATION: STUDENT
No 1 2 3 4 5 6 Name Sandeep Ravin Karan Tarun Zubin Ketaki Stipend 450 400 250 300 500 450 Stream Medical Commerce Humanities Commerce Computers Computers Avgmark 89.2 78.5 64.5 65.7 92 88.5 Grade A B C C A A

1. To display the name of the students who are in medical stream. SELECT Name FROM Student WHERE Stream= Medical; 2. To display name & avg of all students having avgmark<70.0. SELECT Name, Avgmark FROM STUDENT WHERE Avgmark<70.0; 3. To display list of the students with stipend>400 in ascending order of name. SELECT * FROM STUDENT WHERE Stipend>400 OREDER BY Name; 4. To Display the stream & number of students of each stream in the table student. SELECT COUNT (*) FROM student GROUP BY stream ; 5. To Insert a new student in the table INSERT INTO student VALUES(7, 'Sabina', 500, 'computers', 90, 'A'); 6. Give the output: -SELECT MIN(AVGMARK) FROM Student ; MIN(AVGMARK) 64.5 -SELECT COUNT (DISTINCT STREAM) FROM Student; COUNT (DISTINCT STREAM) 4 -SELECT SUM(STIPEND) FROM Student; (SUM STIPEND) 2450

RELATION: SUPPLIER
No 1 2 3 4 5 6 7 8 9 10 Name Sandeep Ravina Karan Tarun Zunbin Ketaki Ankita Zareen Kush Shaliya Age 65 24 45 12 36 16 29 45 19 31 Department Surgery Orthopedic Orthopedic Surgery ENT ENT Cardiology Gynecology Cardiology Nuclear Medicine Datofadm 23-02-11 20-01-11 19-02-11 01-01-11 05/01/98 23-02-98 15-02-98 22-01-98 13-01-98 19-02-98 Charges 300 200 200 300 250 300 800 300 800 400 Sex M F M M M F F F M F

1. To show all information about the patients of cardiology department. SELECT * FROM HOSPITAL WHERE Department= Cardiology; 2. To list the name of female patients who are in orthopedic department. SELECT * FROM hospital WHERE department= orthopedic AND sex='F'; 3. To list the names of all the patients with their date of admission in ascending order. SELECT name FROM hospital OREDER BY Datofadm; 4. To display patient name, charges, age, for only male patients. SELECT name, charges FROM Hospital WHERE sex='M'; 5. To count the number of patient with age>30 SELECT COUNT (*) FROM hospital WHERE age>30; 6.To insert a new row in the hospital table with the following data: (11, Roy, 37, ENT, '26-05-98', 250, 'M'); INSERT INTO Hospital VALUES (11, Roy, 37, ENT, '26-05-98', 250, 'M');

7. Give the output

- SELECT COUNT (DISTINCT DEPARTMENT) FROM Hospital; COUNT (DISTINCT DEPARTMENT) 6 -SELECT MAX(AGE) FROM Hospital WHERE sex='M'; MAX(AGE) 65 -SELECT AVG(CHARGES) FROM Hospital WHERE sex= 'F' AVG (CHARGES) 400 -SELECT AVG (CHARGES) FROM Hospital WHERE datoadm<12-02-98 SUM(CHARGES) 3850

RELATION: BOOKS
BookId F001 F002 F003 F004 F005 BookName The Tears Thunderbolt C++ Brain Work Fast cook Authorname W. Hopkins A. Roberts Brian A. Rossaine Lata Kapoor Publisher First pub1 First pub10 EBP TDH EBP Price 750 700 250 350 300 Quantity 10 5 10 5 8

RELATION: ISSUED
BookId F001 F002 Foo3 QuantityIssued 3 1 5

1.To display name & price of book in ascending order SELECT Bookname, Price FROM Books ORDER BY Price; 2.To increase the price of EPH by 50 UPDATE BOOKS SET Price=Price+50; 3.To show book & author name of EBP Publisher SELECT bookname, authorname FROM books WHERE Publicher= EBP; 4.To display the book Id, book name, quantity issued for all books which have been issued SELECT A.bookId=B.bookId; 5.To Insert a new row in the table issued INSERT INTO ISSUED VALUES(F006, 4);

6.Give the output

-SELECT SUM(PRICE) FROM books WHERE quantity>5; SUM(PRICE) 1350 -SELECT COUNT (DISTINCT PUBLISHERS) FROM Books; COUNT (DISTINCT) 3 -SELECT COUNT(*)FROM Books; COUNT(*) 3 -SELECT Bookname, Authorname, FROM Books WHERE Price<500 Bookname C++ Brainworks Fast cook Authorname Briain A. Rossaine Lata Kapoor

TABLE: CONSIGNOR
CnorId ND01 ND02 ND03 Nd04 CnorName R Singhal Amit Kumar R Kholi S Sing CnorAddress 24,ABC enclave 12, Palm Avenue 5/A, South Street 27,Westend City Delhi Delhi Mumbai Mumbai

TABLE: CONSIGNEE
CneeId MU05 MU08 KO19 MU32 ND48 CnorId ND01 ND02 ND03 ND04 ND01 CneeName Rahul Kishore P Dhingra AP Roy S Mittal BP Jain CneeAddress 5, Park Avenue 16, Moore enclave AB, Colony 13, Vihar CneeCity Mumbai Delhi Mumbai Delhi

2A, Central Avenue Kolkata

1.To Display Names of all Consignors form Mumbai SELECT CnorNAme FROM Consignor WHERE CITY= MUMBAI; 2.To display CneeId,m CnorName, CnorAddress, CneeName, CneeAddress, For every consignee SELECT CneeId, CnorName, Cnor Address, CneeAddress, CneeName FROM Consignor, Consignee Where consignor.CnorId=Consignee.CnorId 3.To display Consignee details in ascending order of Cneename SELECT *FROM Consignee ORDER BY Cneename 4.To display no. of consognor from each city SELECT CITY, COUNT(*) FROM CONSIGNOR GROUP BY city

5.Give the output - SELECT DISTINCT CNEECITY FROM CONSIGNEE

DISTINCT CNEECITY Delhi Kolkata - SELECT A.CnorName, B.CneeName FROM Consignor A, Consignor B WHERE A.CnorId AND B.Cneecity= Mumbai;
A.CnorName R Singhal Amit Kumar B.CneeName Rahul Kishore S Mittal

You might also like