public function getSelectCountSql()
 {
     if ($this->_isGroupSql) {
         $this->_renderFilters();
         $countSelect = clone $this->getSelect();
         $countSelect->reset(Zend_Db_Select::ORDER);
         $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
         $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
         $countSelect->reset(Zend_Db_Select::COLUMNS);
         if (count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
             $countSelect->reset(Zend_Db_Select::GROUP);
             $countSelect->distinct(true);
             $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
             $countSelect->columns("COUNT(DISTINCT " . implode(", ", $group) . ")");
         } else {
             $countSelect->columns('COUNT(*)');
         }
         return $countSelect;
     }
     return parent::getSelectCountSql();
 }
 protected function _initSelect()
 {
     parent::_initSelect();
     $this->getSelect()->joinLeft(array('sales_order' => $this->getTable('sales/order')), '`main_table`.order_id = `sales_order`.entity_id', array('sales_order_created_at' => 'created_at', 'entity_id', 'increment_id', 'store_id', 'subtotal', 'customer_id'));
     return $this;
 }