Go to database->database expert->your datasource->add command and enter the command there. You have to use the syntax/punctuation appropriate to your datasource, so if you are unsure, go to database->show SQL query and observe how the tables and fields are punctuated there, and then use that in creating the command:
select sum(Activity.`tim`) as sumtim, Activity.`act_comment`
from Activity
Group by Activity.`act_comment`
-LB