MYSQLAssignment 1
MYSQLAssignment 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. 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;
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.