The iPhone stores it's SMS message history in an SQLite3 DB file located in the following directory:
/private/var/mobile/Library/SMS/sms.dbOnce you have grabbed the sms.db file, you can open it with your favourite SQLite3 management program (I endorse Sqliteman), and can then proceed to query your data to your hearts content.
Here are some fun queries to try:
(Note: In some of these queries I'm using % LIKE wildcard for matching because some numbers get +1 prepended to them in the phone book)
View all of your messages:
select * from message order by date;Tally up how many messages you've exchanged with each person, and order the list by the message count:
select * from (select count(address) as count, address from message group by group_id) order by count desc;View full message thread with specific person:
select * from message where address like "%4165551234" order by date ascHow many messages you sent someone:
select count(*) from message where address like "%4165551234" and association_id = 0And how many they sent back:
select count(*) from message where address like "%4165551234" and association_id != 0Tally total messages from each area code:
select substr(address,-10,3) as areacode, sum(count) as total from (select count(address) as count, address from message group by group_id) where areacode group by areacode order by count desc;And just for fun, here is a graph generated from this data showing which area code sent me the most messages:
