Re: Got stumped.. Need assistance with a sql query
От | Stephan Szabo |
---|---|
Тема | Re: Got stumped.. Need assistance with a sql query |
Дата | |
Msg-id | Pine.BSF.4.21.0104131807450.59950-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | Got stumped.. Need assistance with a sql query ("Bill Boxall" <bboxall@landover.net>) |
Список | pgsql-general |
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;
В списке pgsql-general по дате отправления: