I am attempting a self join to find groups of records where an attribute is not the same length and the attribute is all numbers.
Here is the query I have so far:
SELECT *
FROM MYTABLE t3
WHERE t3.GROUPID IN (SELECT t1.GROUPID
FROM MYTABLE t1, MYTABLE t2
WHERE t1.FILE_ID <> t2.FILE_ID
AND t1.GROUPID = t2.GROUPID
AND (length(t1.STR_FIELD) <> length(t2.STR_FIELD)))
AND ORIG_GROUPID LIKE 'FRED_E%'
ORDER BY GROUPID ASC;
My table looks like this currently:
-----------------------------
|GROUPID |FILE_ID| STR_FIELD|
| 1 | 12314 | 101 |
| 1 | 54246 | 1011 |
| 2 | 75375 | 202 |
| 2 | 24664 | 202M |
-----------------------------
In the above case, I'd only want GROUPID 1 returned:
-----------------------------
|GROUPID |FILE_ID| STR_FIELD|
| 1 | 12314 | 101 |
| 1 | 54246 | 1011 |
-----------------------------
How can I modify my query to allow this to happen?