Fetch column sum from database and print the output using static/dynamic queries
The first error is caused from the fact that Drupal 7 doesn't define db_result() anymore; it was used from Drupal 6.

The second error is caused from $query-&gt;execute() returning an object of that class, which you cannot convert into a string (which is what you do when you try to print it). You should use code similar to the following code.

$query = db_select('table_name');
$query-&gt;addExpression('SUM(column_name)', 'total');
$result = $query-&gt;execute()-&gt;fetchField();