On 04/07/07, Igor Tandetnik <[EMAIL PROTECTED]> wrote:
select a1.eid, a1.P, a2.subcase from barforce_1 a1 join barforce_1 a2 on (a1.P = a2.P) where not exists (select * from barforce_1 a3 where a3.eid = a1.eid and a3.P < a1.P) order by a1.eid;
Excellent. The only trouble is that I don't understand why it works. I assume that a3.P < a1.P is replacing the MIN(P), but I don't following what is happening. Would you mind explaining?
I'm not sure your query does what you really mean though. Do you intentionally join on P, rather than eid? Consider:
To cover all cases, I would join on both, but as P is in my case a double, there are almost never duplicates. eid P subcase -------------------- 1 10 1 1 20 2 2 30 3 2 40 4 The result of either query (the two should be equivalent) would be eid P subcase -------------------- 1 10 1 2 30 3 i.e. for each element, the minimum P and the subcase at which it occurred. Thanks for the help Jeff ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------