Well a sample group by would look something like this:
Select EMAIL, KEYTYPE, MESSAGE, CP_ID
from mytable
where <criteria>
group by cp_id (or would you want to group by email addy?)
(from your example either way would work)
Your Database should support Group By, I think its standard stuff for...