On Fri, 13 Apr 2001, Bill Boxall wrote:
> Not sure if this is the forum for this.. If it isn't, I'm sure I'll hear
> about it!
>
> I'm looking for help.. Just learning sql, and I'm stuck on this one
> exercise.. A query joining 3 tables.. Here is the question:
>
> List the employee name, job, salary, grade and department name for everyone
> in the company except clerks. Sort on salary, displaying the highest salary
> first.
>
> Here is what I've come up with:
>
> select distinct ename, job, sal, grade, dname from emp, salgrade, dept where
> emp.job != 'CLERK' and emp.deptno = dept.deptno order by sal desc;
You're going to want to limit the rows from salgrade as well...
Probably something like:
select distinct ename, job, sal, grade, dname from emp, salgrade, dept where
emp.job != 'CLERK' and emp.deptno = dept.deptno and
salgrade.losal<=sal and salgrade.hisal>=sal order by sal desc;