Messagin tool

use sql to calculate data instead use each