Re: Select only active entries

Поиск
Список
Период
Сортировка
От Rob Richardson
Тема Re: Select only active entries
Дата
Msg-id 04A6DB42D2BA534FAC77B90562A6A03D01466958@server.rad-con.local
обсуждение исходный текст
Ответ на Re: Select only active entries  (Luiz Eduardo Cantanhede Neri <lecneri@gmail.com>)
Ответы Re: Select only active entries  (Rodrigo E. De León Plicet <rdeleonp@gmail.com>)
Список pgsql-novice
Carel,
 
It is very poor design to assume that records in a database have any order whatsoever.  You are setting yourself up for some very hard-to-find bugs that way.  If you merely add a column named "insert_time" of type timestamp and set its default value to "now()", you will have a guaranteed way to know the order in which records were inserted, and you don't have to change any query that references your table.  Or, you can recreate the table with a column of type "bigserial".  That will automatically set up a sequence that will number the records in the order in which they were inserted.
 
HTH,
 
RobR

 
They are not time stamped but in sequence. The latest active one is basically if  you look at number 5. It goes from active to inactive to active again at time of the query. I want to know if the last entry of ID 5 was active or inactive. And so-forth for all the rest of the ID's. So only select the IDs that were active on their last entry into the database.

Is there a way of querying the data to obtain only the last entry in the table for a given ID?


--
Carel Combrink

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

Предыдущее
От: Luiz Eduardo Cantanhede Neri
Дата:
Сообщение: Re: Select only active entries
Следующее
От: Michael Wood
Дата:
Сообщение: Re: Select only active entries