X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DACDC476683 for ; Sun, 2 Mar 2003 05:12:14 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 05363-09 for ; Sun, 2 Mar 2003 05:12:12 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 9B8F248917D for ; Sat, 1 Mar 2003 23:21:22 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 7B43F43A929; Sat, 1 Mar 2003 23:21:22 -0500 (EST) From: Metnetsky Subject: HardCORE QUERY HELP!!! X-Newsgroups: comp.databases.postgresql.sql Date: Sat, 01 Mar 2003 23:20:29 -0500 Organization: Uberstats User-Agent: KNode/0.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Message-ID: Lines: 30 X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/53 X-Sequence-Number: 12093 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 Table Definition: create table emp (empno numeric(4) not null, ename varchar(10) not null, job varchar(10) not null, mgr numeric(4), hiredate date, sal numeric(6) not null, comm numeric(4), deptno numeric(4) not null, primary key(empno)); Example Data: values(7369,'Martinez','Clerk',7902,'1990-12-17',2800,null,20); values(7499,'Jeter','Sales',7698,'1991-02-20',3600,1300,30); values(7521,'Knoblauch','Sales',7698,'1998-02-22',3250,1500,30); values(7566,'Torre','Manager',7839,'1991-04-02',4975,null,20); values(7654,'Strawberry','Sales',7698,'1994-09-28',2250,2400,30); values(7698,'Dimago','Manager',7839,'1995-05-01', 4850, null,30); values(7782,'Williams','Manager',7839,'1997-06-09',4450,null,10);