X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3FC9F53357 for ; Thu, 31 Mar 2005 03:24:32 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37329-07 for ; Thu, 31 Mar 2005 02:24:11 +0000 (GMT) Received: from alumni.cyut.edu.tw (alumni.cyut.edu.tw [163.17.7.196]) by svr1.postgresql.org (Postfix) with ESMTP id 1A9A552A6A for ; Thu, 31 Mar 2005 03:24:07 +0100 (BST) Received: from cyut.edu.tw (alumni [163.17.7.196]) by alumni.cyut.edu.tw (8.12.11/8.12.11) with ESMTP id j2V2TGou003442 for ; Thu, 31 Mar 2005 10:29:16 +0800 From: "=?BIG5?Q?=AAL=A9?=[=?BIG5?Q?=BEN?=" To: pgsql-sql@postgresql.org Subject: A SQL Question About distinct, limit, group by, having, aggregate Date: Thu, 31 Mar 2005 10:29:16 +0800 Message-Id: <20050331022422.M58459@cyut.edu.tw> X-Mailer: Open WebMail 2.41 20041118 X-OriginatingIP: 163.17.28.64 (s9154083) MIME-Version: 1.0 Content-Type: text/plain; charset=big5 X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200503/403 X-Sequence-Number: 20882 i have a little question, how to get 3 higher score student in every class. Data looks like as below problem: id class score john a 100 jenny a 70 ken a 59 mary b 85 jacky b 80 lily b 70 kevin b 50 david b 30 tina c 85 tony c 80 bare c 70 vivian c 60 eric c 57 andy c 50 result: id class score john a 100 jenny a 70 ken a 59 mary b 85 jacky b 80 lily b 70 tina c 85 tony c 80 bare c 70 -- http://alumni.cyut.edu.tw Open WebMail Project (http://openwebmail.org)