A SQL Question About distinct, limit, group by, having, aggregate

From: "=?BIG5?Q?=AAL=A9?=[=?BIG5?Q?=BEN?=" <s9154083(at)cyut(dot)edu(dot)tw>
To: pgsql-sql(at)postgresql(dot)org
Subject: A SQL Question About distinct, limit, group by, having, aggregate
Date: 2005-03-31 02:29:16
Message-ID: 20050331022422.M58459@cyut.edu.tw
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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)

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jaime Casanova 2005-03-31 03:01:24 Re: A SQL Question About distinct, limit, group by, having, aggregate
Previous Message Chris Browne 2005-03-30 23:04:27 Re: New record position