0% found this document useful (0 votes)
125 views2 pages

Employee Database Query Examples

The document contains 18 SQL queries that retrieve employee data from database tables. The queries select employee names, job titles, salaries, departments, hire dates, and other attributes. They filter on conditions like job type, commission amounts, and date ranges to return specific subsets of employee records.

Uploaded by

Nidhi Patankar
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)
125 views2 pages

Employee Database Query Examples

The document contains 18 SQL queries that retrieve employee data from database tables. The queries select employee names, job titles, salaries, departments, hire dates, and other attributes. They filter on conditions like job type, commission amounts, and date ranges to return specific subsets of employee records.

Uploaded by

Nidhi Patankar
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

[Link] name, job, salary, and annual salary of all employees.

->select ename, job, sal, (sal*12) as 'annual salary' from employee;

[Link] all the different job types.

->select distinct job from employee;

[Link] the name and salary of all employees who are CLERK.

-> select ename, sal, job from employee where job="Clerk";

[Link] the employee number, name, job title, salary and hire date of employees of
department number 20. on december 17, 1980.

-> select * from employee where deptno="20" and (hiredate='1980-12-17');

[Link] the department name and department number for departments with numbers
greater than or equal to 20.

->select dname, deptno from department where deptno>= 20;

[Link] the name, salary and commission of employees whose commission is greater
than their salary

-> select ename, sal, comm from employee where comm> sal;

[Link] the name, job title and salary of everyone hired during 1983

-> select ename, job, sal, year(hiredate) from employee where


year(hiredate)='1983';

[Link] the names of employees where salaries are less than 5500

-> select ename, sal from employee where sal<'5500';

[Link] the names and employee numbers of managers who earn more than 7500.

-> select ename, empno from employee where job='Manager' and (sal>7500);

[Link] the information about managers and the president from the EMP table.
Order by department number.

->select * from employee where job in ('Manager','president') order by


deptno;

[Link] all the employee name that do not end in �S�

-> select ename from employee where ename!='%s';

[Link] the employee names that start with �C�

-> select ename from employee where ename like 'c%';

[Link] the name, job and department of everyone whose name falls in the
alphabetical range �C� to �L�

-> select ename, job, dname from employee e, department d where


[Link]=[Link] and ( ename between 'c%' and 'l%');
[Link] employee details working in department 20, 30 or 40

-> select * from employee where deptno in ('20','30','40');

[Link] of employees while names start with �T� and ends with �R�

-> select ename from employee where ename like 't%r';

[Link] all employees who are hired during 1983

-> select ename, job, year(hiredate) from employee where


year(hiredate)='1983';

[Link] the data as shown below for all employees.


SMITH HAS HELD THE POSITION OF CLERK IN DEPT 20 SINCE 13-JUN-83
ALLEN HAS HELD THE POSITION OF SALESMAN IN DEPT 30 SINCE 13-JUN-83

->select CONCAT(ename, ' HAS HELD THE POSITION OF ',JOB , ' IN DEPT ',deptNo,
' SINCE ', date_format(HireDate,'%d-%M-%Y')) from employee;

[Link] of employees who do not get any commission.

-> select ename, job ,comm from employee where comm is null or comm=0;

You might also like