Re: Got stumped.. Need assistance with a sql query - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Got stumped.. Need assistance with a sql query
Date
Msg-id Pine.BSF.4.21.0104131807450.59950-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Got stumped.. Need assistance with a sql query  ("Bill Boxall" <bboxall@landover.net>)
List 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 by date:

Previous
From: "Chris Jones"
Date:
Subject: Re: Load Text File into DB
Next
From: "Steven D. Arnold"
Date:
Subject: plpgsql -- arrays/temporary tables?