From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Bill Boxall <bboxall(at)landover(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Got stumped.. Need assistance with a sql query |
Date: | 2001-04-14 01:09:53 |
Message-ID: | Pine.BSF.4.21.0104131807450.59950-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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;
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-04-14 01:23:59 | Re: local security |
Previous Message | The Hermit Hacker | 2001-04-14 01:02:18 | Re: anti Christian bias? |