Case 5132 gets returned twice by your first select because it's in two rows.
Then in the state select, two states get returned because there are two states associated with 5132.
I suggest doing something like....
Code:
db2 -x ..... | while read A B C D
do
....
done