Re: What is general term for this problem?

From: Hugo Kornelis <hugo_at_pe_NO_rFact.in_SPAM_fo>
Date: Thu, 16 Sep 2004 22:15:40 +0200
Message-ID: <apsjk096cf9t9norup65rvjarr7fetrfui_at_4ax.com>


On Thu, 16 Sep 2004 12:34:23 -0400, Kenneth Downs wrote:

>The reason this cannot be solved without a loop is that the JOIN between one
>supply row and one demand row actually results in a WRITE to both rows,
>which affects the next JOIN you do. Therefore you must evaluate row by
>row.

Hi Kenneth,

Not necessarily. This kind of problems can often be tackled with a subquery to calculate a running total.

>I have little hope that there is actually a set-based solution, but if I
>have missed something and there is, that would be good news.

Your description is not complete enough to tell for sure, but there might be a set-based solution. It would require several running-total-type subqueries; the whole would probably become rather ugly and it might perform even worse than a cursor-based approach, but if you're determined to do it set-based, it might be possible.

Best, Hugo

-- 

(Remove _NO_ and _SPAM_ to get my e-mail address)
Received on Thu Sep 16 2004 - 22:15:40 CEST

Original text of this message