Why do you need to do a cross join? I can't quite tell from your problem why you can't just do a normal join to PNUM but nor can I quite work out the relation. The fact you have a distinct in there is usually a strong hint you've stuffed up your joining somewhere.
Why do you need to do a cross join? I can't quite tell from your problem why you can't just do a normal join to PNUM but nor can I quite work out the relation. The fact you have a distinct in there is usually a strong hint you've stuffed up your joining somewhere.
Well I chased down the distinct issue, there was a column totally value that I needed to use MAX on to prevent a bunch of duplicates on that. But I'm still not sure how to write the query more efficiently.