query syntax question

From: Lance Massey <lmspam(at)neuropop(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: query syntax question
Date: 2005-04-15 13:22:31
Message-ID: 85939b60c143228dda4aaaf35cfe68fb@neuropop.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm migrating from mySQL where my database tables have an "ID" column
and a an "ID_extended" column. This was done so I could keep a history
e.g. a customer gets an ID when signing on then if they move a new row
is inserted, keeping the old ID, but incrementing the extended ID.

I'm sure there's a better way, but I digress.

In mySQL I could select the most recent addresses with

"Select *, max(ID_extended) from customers group by ID"

In postgreSQL that apparently doesn't work.

If if do:
"Select ID, max(ID_extended) from customers group by ID"

I get a list of the the correct IDs and extended IDs - however, I can't
seem to structure a query where I also retrieve address info.

Is there a way to use the results of that query as inputs to another?
Or is there a better way to write the previous query? Or should I
re-think the data structure since postgreSQL has objects and arrays
available?...

thanks,

L

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Olivier Thauvin 2005-04-15 15:59:09 Re: oids as primary keys?
Previous Message Cima 2005-04-14 21:31:36 data types in stored functions