Re: Need table configuration advice
On Apr 17, 12:05 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> SELECT t1.PartNumber, t2.Revision, t2.Length, t3.Price
> FROM TABLE1 t1
> JOIN TABLE2 t2
> ON t1.PartNumber = t2.PartNumber
> LEFT JOIN TABLE2 t2j
> ON t1.PartNumber = t2j.PartNumber
> AND t2j.Date > t2.Date
> JOIN TABLE2 t3
> ON t1.PartNumber = t3.PartNumber
> LEFT JOIN TABLE2 t3j
> ON t1.PartNumber = t3j.PartNumber
> AND t3j.Date > t3.Date
> WHERE t2j.PartNumber IS NULL AND t3j.PartNumber IS NULL
>
> Be sure to set proper indexes to make the fairly quick.
Thanks. I had to play with that for a while to figure out the how and
why to the way it works. (does anybody use the term 'grok' anymore?)
The next Stupid Newbie question is: What would the proper indexes be?
Just PartNumber or Date as well?
|