$list = $this->table->field("id, add_date, count(ip) ip_count, product_id, count(product_id) product_id_count, category_id") ->where($condition) ->group('product_id') ->order('product_id_count desc') ->order('ip_count desc') ->limit($page->firstRow.','.$page->listRows) ->select();
根据一列,只去重,不统计总点击量:
count(DISTINCT product_id) product_id_count,
->group('product_id')
根据一列,统计总点击量,同时,去重:
count(product_id) product_id_count
->group('product_id')
根据,多列,count,group,order:
$list = $this->table->field("id, add_date, count(ip) ip_count, product_id, count(product_id) product_id_count, category_id") ->where($condition) ->group('product_id') ->order('product_id_count desc') ->order('ip_count desc') ->limit($page->firstRow.','.$page->listRows) ->select();