X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C0802474E61 for ; Mon, 3 Mar 2003 07:44:10 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 55387-06 for ; Mon, 3 Mar 2003 07:44:02 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 59BD3474E42 for ; Mon, 3 Mar 2003 07:44:02 -0500 (EST) Received: from klaster.net (pq55.krakow.cvx.ppp.tpnet.pl [213.76.41.55]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 1DC1A2B880; Mon, 3 Mar 2003 13:42:31 +0100 (CET) Message-ID: <3E634D73.6010702@klaster.net> Date: Mon, 03 Mar 2003 13:41:23 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Metnetsky Cc: pgsql-sql@postgresql.org Subject: Re: HardCORE QUERY HELP!!! References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/67 X-Sequence-Number: 12107 Metnetsky wrote: > Q: list employee name, job, manager name and salary for those whose salary > is more than their manager > > The quetion may seem kinda dumb, it's for a class and my professor has a > thing for brain teaser type questions. I attempted doing this with rename > and a natural join but I can't get the rename to work I think. Any help > would be much appreciated. > Thanx One more version of query you need: select e.ename, e.job, m.ename as managername, e.salary from emp as e join emp as m on (e.mgr=m.empno and e.salary>m.salary); As Rajesh said - for your example data there is no result for such query. Regards, Tomasz Myrta