Re: about SQL problem
From: Ken Denny <ken_at_kendenny.com>
Date: Sat, 28 Sep 2002 16:10:36 GMT
Message-ID: <Xns92977E5A19D98kendenny_at_65.82.44.7>
>> how can i construct a SQL statment to retrieve all red colo rows.
>> the date should be max(date) in each code
Date: Sat, 28 Sep 2002 16:10:36 GMT
Message-ID: <Xns92977E5A19D98kendenny_at_65.82.44.7>
odd.morten.sveas_at_accenture.com (Odd Morten Sveås) wrote in news:4306a83.0209271300.3f1094cb_at_posting.google.com:
> " Q O " <_at_@> wrote in message news:<3d9418b6_at_shknews01>...>>
>> table_1
>> code num units price date
>> 1 1 1
>> 2002-07-02 1 7 1.5
>> 2002-07-08 2 2 5
>> 2002-07-03 2 1 2.3
>> 2002-07-04 2 4 2
>> 2002-07-28 3 3
>> 1.5 2002-07-01 3 2
>> 1.235 2002-07-10
>> how can i construct a SQL statment to retrieve all red colo rows.
>> the date should be max(date) in each code
> > It migth be helpfull if you provided a litle more hints. What du you > acctualy want?
I don't know what "red colo rows" means but I'm guessing he wants for each code, the row which contains the max date for that code. The query is:
select * from table_1 t1 where t1.date = (select max(date) from table_1 t2 where t2.code = t1.code);
-- Ken Denny http://www.kendenny.com/Received on Sat Sep 28 2002 - 18:10:36 CEST