pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 71062.1056@compuserve.com
To: pgsql-sql@postgresql.org
Subject: Re: Simple Query HELP!!!
Date: 23 Sep 2001 20:49:13 -0700
Message-ID: <c0d87ec0.0109231949.4080c0a1@posting.google.com> (raw)
References: <a27df63d.0109221818.2347f039@posting.google.com>

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.



view thread (5+ messages)  latest in thread

Message-ID: <c0d87ec0.0109231949.4080c0a1@posting.google.com>
Permalink:  ../c0d87ec0.0109231949.4080c0a1@posting.google.com/
Also on:    postgresql.org/message-id/c0d87ec0.0109231949.4080c0a1@posting.google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: 71062.1056@compuserve.com
  Subject: Re: Simple Query HELP!!!
  In-Reply-To: <c0d87ec0.0109231949.4080c0a1@posting.google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox