Re: a better soln anyone???

From: Noel <tbal_at_go2.pl>
Date: Tue, 23 Oct 2001 17:33:14 +0200
Message-ID: <3bd58dbe$1_at_news.vogel.pl>


Użytkownik "Bliss" <bliss_is_ignorance_at_hotmail.com> napisał w wiadomości news:3bd44583$1_1_at_news.tm.net.my...
> Hi all,
>
> I have this table which will be containing about 1,00,000 records and will
> grow. The data is some what as follows
>
> ID ITEM PRODUCT NEXT ORDER DATE
> 1 ITEM-01 P1
> 2 ITEM-02 P2
> 3 ITEM-01 P3
> 4 ITEM-03 P4
> 5 ITEM-01 P5
> 6 ITEM-01 P6
> 5 ITEM-04 P1
Is that mistake or there is 2 rows with id 5?

> I need to process records from this table serially to find the next order
> date... When I process ITEM-01, I need to check the next order date for
> which product of ITEM-01 is earliest and show this up on the screen. My
> problem is that when I process the records serially (using a cursor), all
> records of ITEM-01 are going to be processed 4 times (in this case). Any
> way I can avoid this? Am I missing out on some Oracle provided syntax or
> anything which will allow me check / eliminate proceed records? I'm trying
> to avoid using another flag and set it before I start processing as this
> table's going to be massive and the rollback segment may not extend....
>
> Any suggestions are greatly appreciated....
>
>
My suggestion is use GROUP BY ITEM clause and Max(NEXT_ORDER_DATE) in SELECT Statetment.

SELECT ITEM, Max(NEXT_ORDER_DATE)....
  GROUP BY ITEM; Received on Tue Oct 23 2001 - 17:33:14 CEST

Original text of this message