$result=M('sale_lead')
->field('lead_source,created_by,count(sale_lead_id ) as count_num')
->group('lead_source,created_by')
->where($where)
->select();
结果:
array(14) {
[0] => array(3) {
["lead_source"] => string(1) "1"
["created_by"] => string(2) "42"
["count_num"] => string(1) "1"
}
[1] => array(3) {
["lead_source"] => string(1) "3"
["created_by"] => string(2) "43"
["count_num"] => string(1) "1"
}
[2] => array(3) {
["lead_source"] => string(1) "4"
["created_by"] => string(2) "29"
["count_num"] => string(1) "2"
}
[3] => array(3) {
["lead_source"] => string(1) "5"
["created_by"] => string(2) "29"
["count_num"] => string(1) "1"
}
[4] => array(3) {
["lead_source"] => string(1) "5"
["created_by"] => string(2) "42"
["count_num"] => string(1) "1"
}
[5] => array(3) {
["lead_source"] => string(1) "6"
["created_by"] => string(2) "29"
["count_num"] => string(1) "2"
}
[6] => array(3) {
["lead_source"] => string(1) "7"
["created_by"] => string(2) "42"
["count_num"] => string(1) "1"
}
[7] => array(3) {
["lead_source"] => string(1) "7"
["created_by"] => string(2) "43"
["count_num"] => string(1) "2"
}
[8] => array(3) {
["lead_source"] => string(1) "8"
["created_by"] => string(2) "42"
["count_num"] => string(1) "5"
}
[9] => array(3) {
["lead_source"] => string(1) "8"
["created_by"] => string(2) "43"
["count_num"] => string(1) "2"
}
[10] => array(3) {
["lead_source"] => string(2) "13"
["created_by"] => string(2) "43"
["count_num"] => string(1) "1"
}
[11] => array(3) {
["lead_source"] => string(2) "43"
["created_by"] => string(2) "43"
["count_num"] => string(1) "2"
}
[12] => array(3) {
["lead_source"] => string(2) "44"
["created_by"] => string(2) "43"
["count_num"] => string(1) "1"
}
[13] => array(3) {
["lead_source"] => string(2) "45"
["created_by"] => string(2) "43"
["count_num"] => string(1) "1"
}
}