Experiment No: 8
Implementation of order by, group by & having clause.
AIM
Create two tables:
- Dept (Department_Id, Department_Name, Manager_id, Loc)
- Emp(Emp_no, Emp_name,Job, Salary, Hiredate,Comm, Depno)
MANAGER_ID is the empno of the employee whom the employee reports to. DEPTNO is a foreign key. Insert these values into department table
- Display the name and salary for all employees whose salary is not in the range of 5000 and 35000
- Display the employee name, job ID, and start date of employees hired between February 20, 1990, and May 1, 1998. Order the query in ascending order by start date.
- List the name and salary of employees who earn between 5,000 and 12,000, and are in department 2 or 4. Label the columns Employee and Monthly Salary, respectively.
- Display the name and hire date of every employee who was hired in 1994.
- Display the name, salary, and commission for all employees who earn commissions. Sort data in descending order of salary and commissions.
- Display the name and job title of all employees who do not have a manager.
- Display the names of all employees where the third letter of the name is an a.
- Display the name of all employees who have an a and an e in their name.
- Display the name, job, and salary for all employees whose job is sales representative or stock clerk and whose salary is not equal to 2,0000, 4000, or 7,000.
- Write a query that displays the employee's names with the first letter capitalized and all other letters lowercase and the length of the name for all employees whose name starts with J, A, or M. Give each column an appropriate label. Sort the results by the employee's names.
- Write a query to display the number of people with the same job.
- Display the manager number and the salary of the lowest paid employee for that manager. Exclude anyone whose manager is not known. Exclude any group where the minimum salary is less than 6000. Sort the output in descending order of salary
COMMANDS
Create tables
Insert data into table
Queries
- Display the name and salary for all employees whose salary is not in the range of 5000 and 35000
- Display the employee name, job ID, and start date of employees hired between February 20, 1990, and May 1, 1998. Order the query in ascending order by start date.
- List the name and salary of employees who earn between 5,000 and 12,000, and are in department 2 or 4. Label the columns Employee and Monthly Salary, respectively. /
- Display the name and hire date of every employee who was hired in 1994
- Display the name, salary, and commission for all employees who earn commissions. Sort data in descending order of salary and commissions.
- Display the name and job title of all employees who do not have a manager.
- Display the names of all employees where the third letter of the name is an a.
- Display the name of all employees who have an a and an e in their name.
- Display the name, job, and salary for all employees whose job is sales representative or stock clerk and whose salary is not equal to 2,0000, 4000, or 7,000.
- Write a query that displays the employee's names with the first letter capitalized and all other letters lowercase and the length of the name for all employees whose name starts with J, A, or M. Give each column an appropriate label. Sort the results by the employee's names.
- Write a query to display the number of people with the same job.
- Display the manager number and the salary of the lowest paid employee for that manager. Exclude anyone whose manager is not known. Exclude any group where the minimum salary is less than 6000. Sort the output in descending order of salary