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

MYSQLAssignment 1

The document provides instructions for 30 SQL queries to be performed on an EMPL database table containing employee data. The table structure and sample data is provided. The queries include selecting, inserting, updating, deleting data as well as aggregation functions, sorting, filtering and other SQL operations.

Uploaded by

Pinchu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

MYSQLAssignment 1

The document provides instructions for 30 SQL queries to be performed on an EMPL database table containing employee data. The table structure and sample data is provided. The queries include selecting, inserting, updating, deleting data as well as aggregation functions, sorting, filtering and other SQL operations.

Uploaded by

Pinchu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MYSQL Assignment -1

On the basis of above relation EMPL write correct SQL query to perform following task.
Empno Ename Job Mgr Hiredate Sal Comm Deptno
8369 SMITH CLERK 8902 1990-12-18 800 NULL 20
8499 ANYA SALESMAN 8698 1991-02-20 1600 300.00 30
8521 SETH SALESMAN 8698 1991-02-22 1250.00 500.00 30
8566 MAHADEVAN MANAGER 8839 1991-04-02 2985.00 NULL 20
8654 MOMIN SALESMAN 8698 1991-09-28 1250.00 1400.00 30
8698 BINA MANAGER 8839 1991-05-01 2850.00 NULL 30
8882 SHIAVNSH MANAGER 8839 1991-06-09 2450.00 NULL 10
8888 SCOTT ANALYST 8566 1992-12-09 3000.00 NULL 20
8839 AMIR PRESIDENT NULL 1991-11-18 5000.00 NULL 10
8886 ANOOP CLERK 8888 1992-01-12 1100.00 NULL 20
8844 KULDEEP SALESMAN 8698 1992-09-08 1500.00 0.00 30
8900 JATIN CLERK 8698 1991-12-03 950.00 NULL 30
8902 FAKIR ANALYST 8566 1991-12-03 3000.00 NULL 20

1 Create database Employee.


2 Use database Employee.
3 Drop table EMPL if exists.
4 Create table EMPL has following attributes and their type.
empno decimal, ename varchar, job varchar, mgr decimal, hiredate date, sal decimal,
comm decimal, deptno decimal,
5 Insert above said values in EMPL table.
6 Display all the records (all coloumns) from the table EMPL.
7 Display EmpNo and EName all all employees from the table EMPL.
8 Display Ename, Sal and Sal added with Comm from table EMPL.
9 Display employee name, salary and department number who are not getting
commission from table EMPL.
10 Display employee number, name sal and sal*12 as annual salary whose commission is
not NULL from table EMPL.
11 List all department number in table EMPL.
12 List all unique department numbers in table EMPL.
13 List details of all clerks who have not been assigned departments as yet.
14 List the details of those employees who have four lettered names.
15 List the details of all employees whose salary is between 25000 – 40000.
16 How many jobs types are offered to employees?
17 List the details of those employees who earn more commission than their salaries.
18 Display the name, job title and salary of employee who do not have manager.
19 Display the name of the employee whose name contains ‘A’ as third alphabet.
20 Display the name of employee whose name contains ‘T’ as the last alphabet.
21 Display the name of employee who is having ‘L’ as any alphabet of the name.
22 Display details of all employees in reverse order of attributes from table EMPL.
23 Display the structure of table EMPL.
24 Display details of employee whose job is clerk and salary is more than 1000.
25 Display details of employee whose job is in the list (‘CLERK’, ‘SALESMAN’).
26 List the details of all employees whose salary is not between 25000 – 40000.
27 Display details of employee whose job is not in the list(‘MANAGER’, ‘ANALYST’).
28Display the name of the employee whose name does not contains ‘A’ as third alphabet.
29 List the details of all employees in ascending order of name.
30 List the details of all employees in descending order of salary.
31 How to insert data from another table EMPL1 into table EMPL.
32 What will be the output of following SQL command.
a) Select char(70);
b) Select ltrim (‘ RDBMS MYSQL’);
c) Select round(15.193,1) “Round”;
d) Select dayofyear(‘2020-02-13’);
e) Delete from empl;
33 Drop table EMPL. 35. Differentiate alter and update command.
34. Explain following terms.
Relation, domain, tuple, attribute, degree, cardinality
35. Differentiate primary key and unique key. 38. Compare DDL and DML.
Q1 Write SQL commands and outputs on the basis of table GRADUATE.
Table: GRADUATE
S.NO. NAME STIPEND SUBJECT AVERAGE DIV
1 KARAN 400 PHYSICS 68 1
2 DIVAKAR 450 COMPUTER SC 68 1
3 DIVYA 300 CHEMISTRY 62 2
4 ARUN 350 PHYSICS 63 1
5 SABINA 500 MATHEMATICS 70 1
6 JOHN 400 CHEMISTRY 55 2
7 ROBERT 250 PHYSICS 64 1
8 RUBINA 450 MATHEMATICS 68 1
9 VIKAS 500 COMPUTER SC 62 1
10. MOHAN 300 MATHEMATICS 57 2

1. List the names of those students who have obtained DIV 1 sorted by NAME.
2. Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a
year assuming that the STIPEND is paid every month.
3. To count the number of students who are either PHYSICS or COMPUTER SC graduates.
4. To insert a new row in the GRADUATE table:
11, “KAJOL”, “COMPUTER SC”, 75
5. To display the names of all students whose name starts with “A”
6. To change the subject to “PHYSICS” of all students whose stipend is more than 400
7. Increase the stipend of all students by 500
8. To display a report , showing name, subject and bonus (10% of stipend) for all students
9. To list all students sorted by subject in descending order
10. Give the output of following SQL statement based on table GRADUATE:
a) Select MIN(AVERAGE) from GRADUATE where SUBJECT= “PHYSICS”;
b) Select SUM(STIPEND) from GRADUATE where DIV=2;
c) Select AVG(STIPEND) from GRADUATE where AVERAGE>=65;
d) Select COUNT(distinct SUBJECT) from GRADUATE;

Q2 In a database, there are two tables given below:


Table: EMPLOYEE
EMPID NAME SALES JOBID
E1 SUMIT SINHA 110000 102
E2 VIJAY SINGH TOMAR 130000 101
E3 AJYA RAJPAL 125000 103
E4 MOHIT RAMANI 140000 102
E5 SHAILJA SINGH 145000 103

Table: JOB
JOBID JOBTITLE SALARY
101 VICE PRESIDENT 200000
102 ADMINISTRATION ASSISTANT 125000
103 PRESIDENT 80000
104 ADMINISTRATION 70000
105 ACCOUNTANT 65000

a) To display employee ids, names of employees, job ids with corresponding job titles.
b) To display names of employees, sales and corresponding job titles who have achieved sales
more than 130000.
c) To display names and corresponding job titles of those employees who have
‘SINGH’(anywhere) in their names.
d) Identify foreign key in the table EMPLOYEE
e) Write SQL command to change the JOBID to 104 of the EMPLOYEE with ID as E4 in the
table ‘EMPLOYEE’
f) Find out the number of employees having ‘MANAGER’ as job.
g) List the count of employees grouped by JOBID
h) List the sum of employees salaries grouped by JOBID
i) List the maximum salary of employee grouped by their department number
j) List the JOBTITLES name and the number of their employees.

You might also like