Re: sql question

Tech-Archive recommends: Fix windows errors by optimizing your registry



Naughty boy!!!!

Normalise your data!!!!

so your table would have a the following 4 fields

Unique Key / ColKey / C1 / d1

Example
1 1 1 01/jan/2008
2 1 5 02/jan/2008
3 1 10 10/Jan/2008

4 2 4 01/jan/2008
5 2 NULL NULL
6 2 NULL NULL

them simply qry the above table as below:

select f.colkey, f.col1,f.col2
from
(select colkey, min(col2) as col2
from Table where col1 is not null group by colkey
) as x inner join Table f on f.colkey = x.colkey and f.col2 = x.col2

if you have sql 2005 you can easily use CTE

Hope this helps

Regards

Adam Issat
.