query syntax question

Поиск
Список
Период
Сортировка
От Lance Massey
Тема query syntax question
Дата
Msg-id 85939b60c143228dda4aaaf35cfe68fb@neuropop.com
обсуждение исходный текст
Ответы Re: query syntax question  (Bruno Wolff III <bruno@wolff.to>)
Список 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


В списке pgsql-novice по дате отправления:

Предыдущее
От: "Cima"
Дата:
Сообщение: data types in stored functions
Следующее
От: "Cima"
Дата:
Сообщение: oids as primary keys?