Beruflich Dokumente
Kultur Dokumente
Queries:
1. To select all the columns of the above table.
Code:
select * from employee;
Output:
2. To list the name and employee number from the above table.
Code:
select ename,empno from employee;
Output:
5. To list the employee name and his annual salary (annual salary=12*sal +100).
Code:
select ename,sal*12+100 as 'Annual Salary' from employee;
Output:
6. To convert the designation into lower case.
Code:
select lcase(job) from employee;
Output:
7. To list the name and the employee number by converting the name into uppercase.
Code:
select ucase(Ename),EMPNO from employee;
Output:
8. Display the first three characters of the field JOB.
Code:
select substring(job,1,3) from employee;
Output:
10. To list all the columns where salary is greater than 4100.
Code:
select * from employeewhere sal>4100;
Output:
11. Display the ename and sal where the comm is NULL.
Code:
select ename,sal from employeewhere comm is null;
Output:
17. To list the names and job of all the employees who work in 20 and their manager is 7788.
Code:
select ename,job from employee where dept=20 AND mgr=7788;
Output:
18. To list all details of those whose salary is between 3000 and 4000.
Code:
select * from employee where sal Between 3000 AND 4000;
Output:
19. To display the employee name and job of employees hired between Feb 20, 1981and May
1, 1981.
Code:
select ename,job from employee where hiredate between '1981-02-20' AND
'1981-05-01';
Output:
21. To list the names of all employees where the second letter of their name is an ‘a’.
Code:
select ename from employee where ename like "_a%";
Output:
22. To list ename column in the ascending order of hiredate.
Code:
select ename from employee order by hiredate;
Output:
23. To list all the columns in the ascending order of deptno and descending order of salary.
Code:
select ename from employee order by dept ASC,sal DESC ;
Output:
24. Display the ename and deptno of all employees in department 20 and 30 in alphabetical
order by name.
Code:
select ename,dept from employee where dept IN(20,30) order by ename;
Output:
27. SELECT ENAME, 12*SAL + COMM FROM EMPLOYEE WHERE ENAME = ‘Ashok
Singhal’;
Output: