DBA Alhasan Mohammed
DBA Alhasan Mohammed
Submitted by:
Alhasan Mohammed
Result:
Explanation: i compared the salary of employees that are more than the average of
salaries in the table
Result:
Explanation: checked the employees whose salaries are equal to the highest salary
3- Find Employees Working in the Same Department as 'Azad’
Result:
Explanation: checked the employees who are under the same department name as azad
select ename,job from emp where job=(select job from emp where
ename="Newroz")
Result:
Explanation: checked all those who have the same job name as newroz
5- Find Departments That Have More Than One Employee:
Result:
Explanation: checked the department names that have more than 1 employees by
comparing to the numbers of employees in each department (using group by)
6- Find Employees in the Department with the Lowest Average Salary:
Result:
Explanation: checked the lowest average salary in each department by grouping the
department names and then order them based on the average of the salaries of
employees, (note: since grouping by department will result in multiple rows output,
I limit it by one to specify the lowest average salary since its ascending)
7- Find Employees Who Earn More Than the Highest Paid Employee in 'BA' Department:
SELECT sal,ename,deptname FROM emp WHERE sal > ( SELECT max(sal) FROM emp
where deptname="BA");
Results:
Explanation: I compared salary of employees with the highest salary form BA department
SELECT deptname FROM emp WHERE sal <= 5000 group by deptname
Result:
Explanation: i compared the salaries of every employee of every department that are less
or equal to 5000 and to avoid redundancy i grouped them by deptname