$sql = 'select sum(amount) as amount from option_capital where status = 2 and amount > 0 and user_id = '.$user_id; $ret = $this->query($sql);