in reply to using fetchrow_hashref

The keys of the hash being returned are the column headers. You aren't asking for sum(number). You're asking for number.

You can use an "AS" clause to help there:

SELECT code, sum(number) AS number FROM surname_26 group by code

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.