How to find out top 3 records in each location

Поиск
Список
Период
Сортировка
От wen tseng
Тема How to find out top 3 records in each location
Дата
Msg-id 00e001c70cc6$926292a0$6f0aa8c0@miswen
обсуждение исходный текст
Ответы Re: How to find out top 3 records in each location
Re: How to find out top 3 records in each location
Список pgsql-sql
On PostgreSQL, I have a table like this:
 
Item     Location    Sales
 A            X             10
 B            X              6
 C            Y              3
 D            Y              8
 E            Y              15
 F            Y             11
 
I'd like to find out top 3 items in each location and put those 3 items as colum values like this:
 
Location    Top1   Top2   Top3
  X              A        B
  Y             E         F        D
 
Since PostgreSQL doesn't support TOP, how can I do to get this result?
Any solution will be appreciated.
 
Thank you in advance.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: tsvector_eq appears to be inconsistent.
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: How to find out top 3 records in each location