I've got a problem and my limited SQL knowledge it now being tested, and I'm passing this on to you smart folks.. (Oracle DB)..
I have a table with data similar to this where the columns are ORDERID, SALESPERSON, PRODUCTID
123, TIM, PRODUCTA
123, TOM, PRODUCTA
123, MARY, PRODUCTB
124, JOE, PRODUCTA
125, TIM, PRODUCTA
125, TIM, PRODUCTC
126, JOE, PRODUCTA
127, TIM, PRODUCTB
127, TIM, PRODUCTA
.
.
And it's going to be huuuuuuuuuuuge.. So I have this need to run a query which would only match at a maximum on X (let's say X=2) unique order ids returned...
So if I did a search for all ORDERID < 500 I'd get something like:
123, TIM, PRODUCTA
123, TOM, PRODUCTA
123, MARY, PRODUCTB
124, JOE, PRODUCTA
I know that I always wouldn't get the 123 and 124 results, that's not important it's just important that the number of unique ORDERIDs found matching my search is limited to X (or 2) hits..
hints?
I have a table with data similar to this where the columns are ORDERID, SALESPERSON, PRODUCTID
123, TIM, PRODUCTA
123, TOM, PRODUCTA
123, MARY, PRODUCTB
124, JOE, PRODUCTA
125, TIM, PRODUCTA
125, TIM, PRODUCTC
126, JOE, PRODUCTA
127, TIM, PRODUCTB
127, TIM, PRODUCTA
.
.
And it's going to be huuuuuuuuuuuge.. So I have this need to run a query which would only match at a maximum on X (let's say X=2) unique order ids returned...
So if I did a search for all ORDERID < 500 I'd get something like:
123, TIM, PRODUCTA
123, TOM, PRODUCTA
123, MARY, PRODUCTB
124, JOE, PRODUCTA
I know that I always wouldn't get the 123 and 124 results, that's not important it's just important that the number of unique ORDERIDs found matching my search is limited to X (or 2) hits..
hints?