Reputation: 1
I need help with a query DB2.
My table looks like this:
IP_ID IP_TYPE_CDE UPDT_DT_TM
------------- ----------- --------------------------
47560147. 39 2012-11-06-04.16.21.000000
47560147. 319 2013-06-12-16.54.09.000000
47560002. 39 2012-11-06-04.16.21.000000
47560002. 319 2013-06-12-16.54.09.000000
47560003. 39 2012-11-06-04.16.21.000000
47560003. 39 2013-06-12-16.54.09.000000
I need to scan the database, catch all the IP_ID and compare it to that IP_ID had change in IP_TYPE_CDE.
I.e., in this case it should return only IP_ID 47560147 and 47560002.
Upvotes: 0
Views: 1439
Reputation: 312219
You could group by ip_id
and filter by a having
clause that counts the distinct number of ip_type_cde
s:
SELECT ip_id
FROM mytable
GROUP BY ip_id
HAVING COUNT (DISTINCT ip_type_cde) > 1
Upvotes: 1