Re: sql query problem

From: Lawrence James <james.lawrence_at_epamail.epa.gov>
Date: 1996/01/25
Message-ID: <james.lawrence.153.000959D9_at_epamail.epa.gov>#1/1


In article <4dog2a$cqh_at_template.com> Heather Dyson <heather.dyson_at_template.com> writes:
>From: Heather Dyson <heather.dyson_at_template.com>
>Subject: sql query problem
>Date: 19 Jan 1996 16:15:06 GMT
 

>I have a table that has a primary key of
>number, code, month
 

>Let's say that I have the following data
 

>number code month
>------ ---- -----
>1 a 1
>1 b 1
>1 b 2
 

>I want to formulat a query so that I get only the rows with the greatest
>month values for number and code. So the result of my query for the
>example would be
 

>number code month
>------ ---- -----
>1 a 1
>1 b 2
 

>I know this is probably easy, but I would appreciate any help.
>Thanks,
>Heather

Select number, code, max(month)
from table
group by number, code;

Lawrence..... Received on Thu Jan 25 1996 - 00:00:00 CET

Original text of this message