>>Does it has to be in one select? E.g. say, can you select all your operators first, then check, if their routes and dates match the interval?
>
>Well there are thousands of recs in the ET table, and their dates can vary, so each rec has to be checked at read time to get its SERVETYPE from RteFam (Route Family). One Serve Type could expire mid-month and be replace with a different scheme, for the same route.
>
>Anyhow, the SQL is taking too long (and esp. since I have to add the "infinite" clauses) so I think I'll need to pre-SQL it into an array and use this in a look-up function instead.
>
>
>>
>>Also please apply Fabio's suggestion to this select before anyone can proceed making any sense of it.
>>
>
>Whatever, I don't think that these detract from the "sense" of the SQL, but I'll need to look into that, for sure. BTW, have you ever looked at some of the complex SQL you often post, with crammed up text and no formatting or indenting? I find them almost impossible to read.
Yes, I agree. Lots of times it's hard to look into someone's select (mine included) and understand, what it's doing and what is its purpose. Sergey and Fabio are really good in deciphering those beasts...
If it's not broken, fix it until it is.
My Blog