$sql = "user_id in (".$userList.") and date_format(date, '%Y%m') = {$date} and type = {$type}";
$data= Yii::app()->db->createCommand()->from("{{reminder_sales}}")
->select("*")
->where($sql)
->group('user_id')
->text;
$data= Yii::app()->db->createCommand()->from("($data) as v")
->select('count(*) as total')
->queryScalar();