The document describes the creation of EMP and DEPT tables in a database. The EMP table stores employee data like employee number, name, job, manager, hire date, salary, commission, and department number. It has constraints like primary key and foreign key. The DEPT table stores department data like department number, name, and location. It also has a primary key constraint. Sample data is inserted into both tables.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
57 views
SQL Practice
The document describes the creation of EMP and DEPT tables in a database. The EMP table stores employee data like employee number, name, job, manager, hire date, salary, commission, and department number. It has constraints like primary key and foreign key. The DEPT table stores department data like department number, name, and location. It also has a primary key constraint. Sample data is inserted into both tables.
INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');
INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');
INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');
INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON');
Assignment:
1. Retrieve the entire contents of EMP table.
select * from EMP;
2. Print the name of employees.
3. Retrieve the list of names and jobs of employees. 4. List of various department available from dept table. 5. List names of employees whose job is MANAGER. 6. List names of employee having salary greater than equal to 3000. 7. List all employees having ‘A’ as second letter in their names. 8. List all information about the Employees and the structure of the EMP table. 9. Select the structure of the DEPT table. Show the information of the Department table. 10. the contents of the column Empno, Ename as Employee Name and Sal from the Emp table.Display 11. List the Employee Number, Name, Hiredate and Job Title of the Employees in the Department 10. 12. Display the details of those Employees who earn a monthly Salary of more than 2000. 13. Display the names of all Employees from Department 10 and 20 whose name start with “A” and ends with “B”. 14. Display the details of the employees who have joined on 21-DEC-1990. 15. Display the Job, Comm and Ename from the Emp table with Customized column headings. 16. Display the Employee Code, Name, Job & Annual Salary for all Employees belonging to Department Number 10. 17. Display the details of the Employees who earn an Annual salary of more than 25000. Sort the records in the descending order of Salary. 18. Display the names of Employees whose names contain the character “F”. 19. Display the location as “Location” and names of all the departments as “Department Names”. 20. Display the Names and Numbers of all Departments in the descending order of the Department Names. 21. Display the Name, Employee Number, Designation and Salary of those Employees who earn a monthly salary of not less than 1000 and not more than 2000. 22. Find out the Bonus (Bonus 1.1% of Annual Salary) that every person will receive at the end of the year. 23. Display the Name, Job and Dept No. of all the Employees who either work in Department 30 or in Department 40. 24. Display the Employee Number, Name for Clerks and Managers who’s Salary is more than 1500. 25. Display the Name, Annual Salary and Commission as “Commission Earned” of all employees whose monthly salary is greater than their Commission. The output should be in decreasing order of salary. If two or more employees have same salary, then sort them by name within the highest order of salary. 26. Display the Name and Job of sales executives or managers whose names end with the letter ‘S’. 27. Display all the Names of the Employees whose Salary is either more than 1000 but not more than 2200. 28. Select Name & Salary of employees who are clerks. 29. List the Department Number and Names of all Employees having Salary less than 2500.