Create Virtual Query
Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.
$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write''core_read'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns(array('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)')) )->group('mage_art_works.artist_id'); Alias table using above result:
then add the below ZEND SQL to the alias table
$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr(" ( $select ) ")), 'main_table.user_id = art.artist_id', array() );