Professional Documents
Culture Documents
Practical Examination 2020 Ip Set 1
Practical Examination 2020 Ip Set 1
8
Total =
SQL Queries with Solution
Q.2- Consider the above table as "emp" and first column is 'empno' as primary key. Answer the 1x7=7
following sql queries.
a) Add a row with empno 1008 as Robin,Analyst,60000,2011-04-01,Admin.
Insert into emp values(1008,'Robin','Analyst',60000,'2011-04-01','Admin');
b) Display the detail of all employees whose salary lies in the range 50000 and 100000.
Select * from emp where salary between 50000 and 100000;
c) Display average salary and no. of employees of each department.
Select department, avg(salary), count(*) from emp group by department;
d) Display maximum salary of each type of job for Clerk and Manager only.
Select job,max(salary) from emp group by job having job in ('Clerk','Manager');
e) increase the salary of sales department employees by 5 percent.
Update emp set salary=salary+salary*0.05 where department='Sales';
f) Delete the column dojoin.
Alter table emp drop column dojoin;
g) Display detail of employees in descending order of their salary.
Select * from emp order by salary desc;
Practical File 5
Project File 5
Viva Voice 5
Solution: Q.1- Program Code:
import pandas as pd
import matplotlib.pyplot as plt
dict1={'ename':['Scott','Tom','Joy','Sam','Martin','Michel','Francis'],
'job':['Manager','Clerk','Clerk','Salesman','Manager','Salesman','Clerk'],
'salary':[90000,34000,32000,40000,85000,43000,30000],
'dojoin':['2010-10-01','2010-01-04','2009-03-01','2009-04-01','2008-08-05','2008-08-06','2009-10-10'],
'department':['Accounts','Admin','Admin','Sales','Sales','Sales','Accounts']}
emp=pd.DataFrame(dict1,index=[1001,1002,1003,1004,1005,1006,1007])
print(emp)
x=emp['salary']*0.15
# Add a new column named Bonus ( just after salary column) which is 15% of their salary.
emp.insert(3,'bonus',value=x)
print(emp)
#Now plot a bar chart depicting the employee name on x-axis and their corresponding
#salary on y-axis, with appropriate Graph title, x-axis title, y-axis title,
#gridlines and color etc.
x=emp['ename']
y=emp['salary']
plt.bar(x,y,color='r')
plt.xlabel('Name-->',fontsize=12,color='g')
plt.ylabel('Salary (Rs.)-->',fontsize=12,color='g')
plt.title('ABC PVT Limited\n Employees Salary analysis', fontsize=14, color='r')
plt.grid()
plt.show()
OUTPUT: