When GetStatistics is called on an empty database, SQL SUM() returns NULL which causes a scan error when converting to int. Wrap SUM expressions with COALESCE to return 0 instead of NULL. Add TestGetStatistics to verify both empty and populated database cases. Fixes issue where `bd stats` and MCP stats tool crash on fresh databases. Signed-off-by: Joshua Shanks <jjshanks@gmail.com>