Professional Documents
Culture Documents
A1 ANS Incomplete
A1 ANS Incomplete
Bank
Corporation' and earn more than $10,000.
2) Find the names of all employees in the database who live in the same cities as the companies for
which they work
Select e.employee-name
//////3) Assume that the companies may be located in several cities. Find all companies located in every
city in which 'Small Bank Corporation' is located.
Select company-name
FROM Company c
/////Q4: Find the names of all employees who earn more than the average salary of all employees of
their company. Assume that all people work for at most one company 39: Find the name of the
company that has the smallest payroll
Select e.employee-name
29) Give names of all those employees who work in the city “London”, take no commission under
manager 3323 and hire before 2002.
Select e.ename
27)Give all data of employees whose salary is less than average salary and department id is 30.
AND d.deptno = 30
26) Give employee number, name, hire date, commission, department id, department name, location,
salary grade of all employees those names are Hassan, salary is less than 50000, commission is 2% of the
half of their salary
From emp
Where LENGTH(ename) = 3
OR LENGTH(ename) = 4
24) Give the employee numbers in ascending order as “Ascending” and in descending order as
“Descending”.
23) Give employee name, hire date, department name and commission of all employees in the format,
e.g “Hanan was hired on 1-12-2001 in department Accounts with commission 2.5%” as Emp Detail, of
those commission is less than 30% of the one third of their salary.
Select ename || ‘was hired on ’ hiredate || ‘in department ’ dname || ‘with’ comm) AS “Emp Detail”
From emp
22) Show all employee names, starting with ‘A’ and second last letter ‘M’
Select ename
FROM emp
20) Give the employee number and hiredate and maxsal of employees those salgrade is greater than 19
and all employees that manger is Adeel.
Where s.grade>19
19) Give salary grade of only those employees whose Manager is 7902 or department id is 30 and
location is Boston or department name is “Operations”.
OR d.deptno =30)
OR d.dname = ‘Operations’)
18) Give salary of all those employees whose name is John and their location is Sydney and also of those
whose name is Smith and their location is not California.
SELECT e.sal
17) Determine the number of managers without listing them. Label the column Number of Managers.
FROM emp
16) Write a query that displays the employee numbers and last names of all employees who work in a
department with any employee whose last name contains a k, and sorted the record on the basis of
employee name
ORDER BY e.ename
15) Display the employee numbers, last names, and salaries of all employees who earn more than the
average salary and who work in a department with any employee with a u in their name.
From emp
FROM emp
GROUP BY mgr
13) Write a query to display each department’s name, location, number of employees, and the average
salary for all employees in that department. Label the columns Name, Location, Number of People, and
Salary, respectively. Round the average salary to two decimal places.
12) Create a query to display the name and hire date of any employee hired after employee SCOTT.
11) Write a query to display the employee name, hire date, number of months employed, first Friday
after hiredate and last day of the month when hired, for all employees employed for fewer than 36
months.
FROM emp
FROM emp
9) Write a query that produces the following for each employee: earns monthly but wants. Label the
column Dream Salaries whose salary ranges in between 1100 to 2900.
FROM emp
8) For each employee, display the employee number, ename, salary, and salary increased by 15% as
New Salary add a column as Increment that subtracts the old salary from the new salary and expressed
as a whole number.
SELECT empno, ename, sal, (sal *0.15) AS “NEW SALARY”, TRUNC(NEW SALARY - sal) AS “INCREMENT”
FROM emp
7) 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 M, T, or K. Sort the
results by the employees’ names.
Where (d.deptno = 20
ORDER BY e.ename