Re: How to find out top 3 records in each location
От | Richard Broersma Jr |
---|---|
Тема | Re: How to find out top 3 records in each location |
Дата | |
Msg-id | 713709.88122.qm@web31813.mail.mud.yahoo.com обсуждение исходный текст |
Ответ на | Re: How to find out top 3 records in each location (Richard Broersma Jr <rabroersma@yahoo.com>) |
Список | pgsql-sql |
Oops, I made a mistake the sub-selects should be item not sales... > SELECT > A1.location, > ( select item ^^^^ > from sales > where location = A1.location > order by sales desc > limit 1 > ) as TOP1, > ( select item ^^^^ > from sales > where location = A1.location > order by sales desc > limit 1 offset 1 > ) as Top2, > ( select item ^^^^ > from sales > where location = A1.location > order by sales desc > limit 1 offset 2 > ) as Top3 > > > FROM > ( SELECT location > from sales > group by location > ) AS A1 > ; > > > Regards, > > Richard Broersma Jr. > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >
В списке pgsql-sql по дате отправления: