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

Assignment 1

Uploaded by

ajaysonawale512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Assignment 1

Uploaded by

ajaysonawale512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1) Select the employee in department 30.

mysql> select * from emp where deptno = 30;


2) List the names, numbers and department of all clerks.
select empno,ename,deptno from emp where job = 'clerk';
3) Find the depart numbers and the name of employee of all dept with Deptno greater
or equal to 20.
select deptno,ename from emp where deptno >=20;
4) Find the employees whose commission is greater than their salary.
select ename,sal,comm from emp where comm >sal;
5) Find the employees whose commission is greater than 60 percent of their salary.
select ename,sal,comm from emp where comm > 0.60 *sal;
6) Find the employee whose commission is greater than 50 percent of their salary.
select ename,sal,comm from emp where comm >0.50 * sal;
7) List the name, job and salary of all employees in dept 20 who earn more than
2000.
select ename,job,sal from emp where deptno = 20 and sal > 2000;
8) Find all salesmen in dept 30 whose salary is greater than or equal to Rs. 1500.
select ename,job ,sal from emp where job = 'salesman' and deptno = 30 and
sal>=1500;
9) Find all the employees whose job is either a president or manager.
select * from emp where job in ('manager', 'president');
10) Find all managers who are not in dept 30.
select ename, job,deptno from emp where deptno != 30 and job = 'manager';
11) Find the details of all managers and clerks in dept 10.
select * from emp where job in('manager','clerk') and deptno=10;
12) Find the details of all manager (in any dept) and all clerks in dept 10
select * from emp where job in('manager') or job = 'clerk' and deptno=10;
13) Find the details of all managers in dept 10 and all clerks in dept 20.
select * from emp where job ='manager' and deptno = 10 or job = 'clerk' and
deptno=20;
14) Find the details of all the manager in dept 10, all clerk in dept 20
select * from emp where job ='manager' and deptno = 10 or job = 'clerk' and
deptno=20;
15) find all employees who are neither clerks nor manager but whose salary is
greater than or equal to Rs. 2000.
select * from emp where job != 'manager' and job != 'clerk' and sal>= 2000;
16) Find the names of everyone in deptno 20 who is neither a clerk nor a Manager.
select * from emp where job != 'manager' and job != 'clerk'and deptno = 20;
17) Find the employees who earns between Rs. 1200 and Rs.1400.
select ename,sal from emp where sal between 1200 and 1300;
18) Find the employees who are clerks, analysts or salesman.
select * from emp where job in('clerk','analyst','salesman');
19) Find the employees who are not clerks, analyst or salesman.
select * from emp where job not in('clerk','analyst','salesman');
20) Find the employees who do not receive a commission.
select * from emp where comm is null ;
21) Find the employee whose commission is Rs. 0.
select * from emp where comm = 0;
22) Find the different jobs of the employees receiving commission.
select job,ename,comm from emp where comm is not null and comm>0 ;
23) Find all employees who do not receive a commission or whose Commission is less
than Rs. 100.
select * from emp where comm is null or comm <100;

24) Find all employees whose names begin with m.


select ename from emp where ename like 'm%';

25) Find all employees whose names end with m.


select ename from emp where ename like '%m';

26) Find all employees whose names contain the letter m in any case.
select ename from emp where ename like '%m%';

27) Find the employees whose names are 5 characters long and end with n.
select ename from emp where ename like '_____n%';

28) Find the employees who have the letter r as the third letter in their name.
select ename from emp where ename like '__r%';

29) Find all employees hired in month of February (of any year).
select * from emp where hiredate like '____-02-__';

30) Find the managers hired in the year 2012.


select * from emp where hiredate like '2012-__-__';

31) Display the names of all employees with any 'a'.


select * from emp where ename like '%a%';

32) Display the name of all employees, and their bonus. Assume each Employee gets a
bonus of 20 percent of his salary subject to the Maximum of Rs. 500.
select ename, sal*0.20 as bonus from emp where sal >=500;

33) Display the name of all employees, and their bonus. Assume each employee gets a
bonus of 20 percent of his salary subject to the Maximum of Rs. 200.
select ename, sal*0.20 as bonus from emp where sal >=200;

You might also like