Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8O43qh02760 for ; Mon, 24 Sep 2001 00:03:52 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f8O3nEL14708 for pgsql-sql@postgresql.org; Sun, 23 Sep 2001 23:49:14 -0400 (EDT) (envelope-from news) From: 71062.1056@compuserve.com (--CELKO--) X-Newsgroups: cz.comp.microsoft.sql, mailing.database.sql-general, comp.databases.ms-sqlserver, comp.databases.postgresql.sql Subject: Re: Simple Query HELP!!! Date: 23 Sep 2001 20:49:13 -0700 Organization: http://groups.google.com/ Lines: 26 Message-ID: References: Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Archive-Number: 200109/253 X-Sequence-Number: 4935 Please write DDL and not narrative. here is my guess at what you are trying to do. What you posted was not a table because you had no key. TEXT is not the datatype to use for names -- unless they are thousand of characters long!! Recording age as an integer is useless -- give us the birthday and we can always compute their age. Is this what you meant to post? CREATE TABLE People (name CHAR(30) NOT NULL PRIMARY KEY, -- not big enough for TEXT age INTEGER NOT NULL, -- should be birthdate instead company CHAR(30) NOT NULL); >> ... create a query than get me a list with the seniors per company, for example :<< SELECT P1.name, P1.age, P1.company FROM People AS P1 WHERE NOT EXISTS (SELECT * FROM People AS P2 WHERE P1.company = P2.company AND P1.age < P2.age); This says there is nobody older than the P1 person in the same company.