>>>
select eval("min(sk, " + str(min(pk)) + ")"), sk from table group by sk
>>
>>Did you try it? Doesn't work for me.
>
>Yep.
>
>Just to be clear, this isn't a replacement for your second SELECT, this is an all in one SELECT.
Right. That's what I tested. My problem was that I was using character fields, not numeric. Even after removing the STR(... I still had a type mismatch.
This does the trick (and a nice trick at that, sir)
select eval("min(sk, " + [']+min(pk)+['] + ")"), sk from table group by sk
Surely there must be some way to make it even more cryptic?
Now let's see if Paul Vlad comes up with a pure SQL for the entire problem :-)