COMPUTER SCIENCE: SQL

Tuesday, June 23, 2009

Some SQL queries for you to solve.....
Consider the table given below and write the commands:




1.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


(a) To display the name, hiredate of all the employee hired after employee Jan 10th 1980.
(b) To display the highest and lowest salary for each department.

(c) To display the name of the employees whose job is in Clerk, Salesman, President
(d) To display all the types of jobs available in EMP table without repeating any.
(e) To display the name and salary of all the employees in the alphabetical order of name.



2.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


To display the ename, deptno and salary of all employee who do not get commission.
To count the number of employees in each department.
To display the ename and hiredate of all the employees whose name start with A.
To display the name, department number for all employees who work as Clerks and earns a salary more than 4000
To display the employee number and employee name in the descending order of salary.



3.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


(a) Display all the records (all columns) from table Emp.
(b) Display the difference of highest and lowest salary of each department
(c ) Display Ename, Sal and Sal added with Comm from table Emp.
(d) Display Ename with heading “Employee”, Sal*12 as “Total Salary” from table Emp.
(e) Display distinct Sal of employees from table Emp




4.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


1. Show the Structure of table EMP
2. Write a query to display EName and Sal of Employees whose salary isgreater than or equal to 3000 in ascending order of employee name.
3. Write a Query to display empno, employee name and department numberof all employees who have manager number between 7500 and 7900.
4. Write a Query to display name, job, salary, and HireDate of employeeswho are hired between February 20, 1981, and May 1, 1981. Order thequery in ascending order of HireDate.
5. Write a Query to display the name of employee whose name contains ‘T’as the last alphabet.

0 comments:

Post a Comment

Blogroll

Bookmark and Share
Powered By Blogger
CBSE 12th Grader.