To all:
Man, I can not figure this out. This is what I am trying to do. Let's say I have a data set of:
Address Zip ID Decile
123 Main St 76132 1 7
123 Main St 76132 2 6
123 Main St 76132 3 1
I am trying to get a result that provides me with the id of the record with the minimum DECILE, but grouped by ADDRESS and ZIP giving me only on unique record per ADDDRESS and ZIP combined, but I need the right record. So the record I am looking for is:
123 Main St 76132 3 1
Here is what I have (works for min(ID)), but can not get the prioity on DECILE to work:
SELECT ID
FROM TABLE
WHERE ID IN (SELECT MIN(A.ID)
FROM TABLE A,
TABLE B
WHERE A.ID = B.ID
HAVING COUNT(A.ID) > 1
GROUP BY PRIMARY_ADDRESS_LINE_1, PRIMARY_ZIP_CD_5)
Any help would be great.
Thanks-
E
Man, I can not figure this out. This is what I am trying to do. Let's say I have a data set of:
Address Zip ID Decile
123 Main St 76132 1 7
123 Main St 76132 2 6
123 Main St 76132 3 1
I am trying to get a result that provides me with the id of the record with the minimum DECILE, but grouped by ADDRESS and ZIP giving me only on unique record per ADDDRESS and ZIP combined, but I need the right record. So the record I am looking for is:
123 Main St 76132 3 1
Here is what I have (works for min(ID)), but can not get the prioity on DECILE to work:
SELECT ID
FROM TABLE
WHERE ID IN (SELECT MIN(A.ID)
FROM TABLE A,
TABLE B
WHERE A.ID = B.ID
HAVING COUNT(A.ID) > 1
GROUP BY PRIMARY_ADDRESS_LINE_1, PRIMARY_ZIP_CD_5)
Any help would be great.
Thanks-
E