Re: pgsql aggregate: conditional max

Поиск
Список
Период
Сортировка
От Weimao Ke
Тема Re: pgsql aggregate: conditional max
Дата
Msg-id 44145569.3010208@indiana.edu
обсуждение исходный текст
Ответ на Re: pgsql aggregate: conditional max  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: pgsql aggregate: conditional max  (Markus Schaber <schabi@logix-tt.com>)
Список pgsql-sql
Michael Fuhr wrote:

>SELECT DISTINCT ON (aid) aid, cat
>FROM tablename
>ORDER BY aid, weight DESC, cat;
>  
>
Good pointer. I think this will solve my problem. :)

>SELECT aid, cat
>FROM tablename AS t
>JOIN (SELECT aid, max(weight) AS weight
>      FROM tablename
>      GROUP BY aid) AS s USING (aid, weight);
>  
>
This query will return duplicates if there are multiple categories (for 
one aid) with the same max weight. Yet, I should be able to remove the 
duplicates somehow...:)

I really appreciate your help!

-- 
All best, 

Weimao

Weimao Ke
Indiana University Bloomington
School of Library and Information Science
http://ella.slis.indiana.edu/~wke



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

Предыдущее
От: Robert Paulsen
Дата:
Сообщение: Question re: relational technique
Следующее
От: chester c young
Дата:
Сообщение: Re: Question re: relational technique