Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 276969FB219 for ; Thu, 19 Oct 2006 08:52:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 82969-07 for ; Thu, 19 Oct 2006 08:51:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.telefor.hu (mail.telefor.hu [193.68.53.97]) by postgresql.org (Postfix) with ESMTP id ED2AB9FB20F for ; Thu, 19 Oct 2006 08:51:58 -0300 (ADT) Received: from telefor-server.int.telefor-new.hu (telefor-server.int.telefor-new.hu [10.0.20.100]) by mail.telefor.hu (Postfix) with ESMTP id 1F0921C04D for ; Thu, 19 Oct 2006 13:51:55 +0200 (CEST) Received: from [10.0.20.33] ([10.0.20.33]) by telefor-server.int.telefor-new.hu with Microsoft SMTPSVC(6.0.3790.1830); Thu, 19 Oct 2006 13:51:55 +0200 Message-ID: <453766DB.6000408@telefor.hu> Date: Thu, 19 Oct 2006 13:51:55 +0200 From: =?UTF-8?B?TWV6ZWkgWm9sdMOhbg==?= Organization: Telefor Kft. User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Grouping by day, limiting amounts Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 19 Oct 2006 11:51:55.0840 (UTC) FILETIME=[F9BE6C00:01C6F374] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.292 tagged_above=0 required=5 tests=AWL, HTML_30_40, HTML_MESSAGE, MIME_HTML_ONLY X-Spam-Level: X-Archive-Number: 200610/175 X-Sequence-Number: 26564 Hi,

I didn't really know what subject I should give.

I have a table like this one:

2006.10.01.    Bela    10
2006.10.01.    Aladar    9
2006.10.01.    Cecil    8
2006.10.01.    Dezso    7
2006.10.01.    Elemer    6
2006.10.02.    Bela    11
2006.10.02.    Aladar    10
2006.10.02.    Cecil    9
2006.10.02.    Dezso    8
2006.10.02.    Ferenc    7
2006.10.03.    Bela    6
2006.10.03.    Aladar    5
2006.10.03.    Cecil    4
2006.10.03.    Dezso    3
2006.10.03.    Jozef    2

The first column is a date, the second is a name, the third is the number of votes that the name received on that day.

I would like to select the 3 (or 10) names with the most votes for each day.

Any suggestions on how can it be done easily?

Thanks,

Zizi