Re: Help with simple query

Поиск
Список
Период
Сортировка
От PFC
Тема Re: Help with simple query
Дата
Msg-id op.s2iujcjfcigqcu@apollo13
обсуждение исходный текст
Ответ на Help with simple query  (Collin Peters <cadiolis@gmail.com>)
Список pgsql-sql
If you want the latest by user, you can cheat a bit and use the fact that  
the id's are incrementing, thus ordering by the id
is about the same as ordering by the date field. I know it can be inexact  
in some corner cases, but it's a good approximation, and
very useful in practice :

SELECT user_id, max(note_id) FROM notes GROUP by user_id;

So :

SELECT * FROM notes WHERE id IN (SELECT max(note_id) FROM notes GROUP by  
user_id) ;

Can postgres use the index on these max() clauses now ?


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

Предыдущее
От: Frank Bax
Дата:
Сообщение: Re: Help with simple query
Следующее
От: "George Pavlov"
Дата:
Сообщение: Re: Help with simple query