I must agree with the various people that have taken issue with the terminology. 'First' implies an order. 'One' does not.
So, basically, you want 1 (random) record for a given contract id. For that, ocp_dev's code will work fine.
If, however, you want 1 (random) record for multiple contract ids, then you will need a slightly different solution.
For 8.1.6.2 or later...
HTH,Code:SELECT CONTRACT_NUM, LOCATION FROM ( SELECT CONTRACT_NUM, LOCATION , ROW_NUMBER() OVER ( PARTITION BY CONTRACT_NUM ) AS RN FROM YOUR_TABLE ) WHERE RN = 1;
- Chris




