0% found this document useful (0 votes)
1 views

SQL commands

The document contains a SQL worksheet with various tasks related to employee and book tables, including commands to display, remove, and add data. It also includes queries for an organization table and employee details, focusing on specific attributes and conditions. The tasks are structured as SQL commands and expected outputs for different scenarios.

Uploaded by

n.madhavan1973
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

SQL commands

The document contains a SQL worksheet with various tasks related to employee and book tables, including commands to display, remove, and add data. It also includes queries for an organization table and employee details, focusing on specific attributes and conditions. The tasks are structured as SQL commands and expected outputs for different scenarios.

Uploaded by

n.madhavan1973
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ANNA ADARSH MATRIC HR SEC SCHOOL

SQL WORKSHEET

1. Consider the following employee table


Write SQL commands for the questions 1 to 5
EMP CODE NAME DESIG PAY ALLOWANCE
M1001 KANNAN MANAGER 30000 5000
O1002 GANESH OPERATOR 15000 2500
O1003 BARGAVI OPERATOR 15000 2500
C1004 MANI CLERK 12000 1500
A1005 BABU ACCOUNTANT 18000 2750

i) To display the details of all employees in descending order of pay.


ii) To display all employees whose allowance is between 2000 and 3500
iii) To remove the employees who are clerk
iv) To add a new row
v) To display the details of all employees who are operators.

2. Write the SQL commands for (i) to (ii) and outputs for (iii) to (vi) on the basis of tables BOOKS and
ISSUES

Table: BOOKS

Book_ID BookName AuthorName Publisher Price Qty

L01 Maths Raman ABC 70 20

L02 Science Agarkar DEF 90 15

L03 Social Suresh XYZ 85 30

L04 Computer Sumita ABC 75 7

L05 Telugu Nannayya DEF 60 25

L06 English Wordsworth DEF 55 12

Table: ISSUES

Book_ID Qty_Issued

L02 13

L04 5

L05 21

(i) To display Book name, Author name and Price of books of ABC publisher.

(ii) To display the details of the books in descending order of their price.

(iii) SELECT sum(price) FROM Books WHERE Publisher = “DEF”;

(iv) SELECT Publisher, min(price) FROM Books GROUP BY Publisher;

(v) SELECT Price from Books, Issues where Books.Book_ID=Issues.Book_ID AND Qty_Issued=5;

(vi) SELECT Count(Distinct Publisher) FROM Books.


3. Write the SQL commands for (i) to (iii) and outputs for (iv) to (v) on the basis of tables BOOKS and
ISSUES
Table : Organisation
ECODE NAME POST SALARY SGRADE DOJ
2001 AJAY GENERAL MANAGER 80000 D003 23-Mar-2003
2002 VIJAY EXECUTIVE 50000 D002 12-Feb-2010
MANAGER
2003 RAM DEPUTY MANAGER 85000 D003 24-Jan- 2009
2004 RAHIM PROD. INCHARGE 78000 D002 11-Aug-2006
2005 ABBAS ADD. GENERAL 70000 D001 19-Jan-1982
MANAGER

(i) To display NAME and POST of those members whose grade is either D002 or D003
(ii) To display the details of all members of organisation in descending order of DOJ.
(iii) To add a new row with the following 2007,’Rudra’,’sales incharge’,’d002’,’19-10-1987’;
(iv) SELECT COUNT(SGRADE), SGRADE FROM organisation GROUP BY SGRADE;
(v) SELECT MIN(salary),MAX(Salary) from organisation;

4. Consider the following tables EMPLOYEES and EMPSALARY. Write SQL commands for the statements
(i) to (ii) and give outputs for SQL queries (iii) to (iv)

(i) To display Firstname,Lastname,address and city of all employees living in paris from the table
EMPLOYEES.
(ii) To display the content of EMPLOYEES table in descending order of Firstname
5. Consider the following tables SCHOOL and ADMIN. Write SQL commands for the statements (i) to (iv)
and give the outputs for SQL queries (v) to (viii)

You might also like