public static function doCountJoinAllExceptClassLevelRelatedByLastClass(Criteria $criteria, $distinct = false, $con = null)
 {
     $criteria = clone $criteria;
     $criteria->clearSelectColumns()->clearOrderByColumns();
     if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
         $criteria->addSelectColumn(NgTestApplicantPeer::COUNT_DISTINCT);
     } else {
         $criteria->addSelectColumn(NgTestApplicantPeer::COUNT);
     }
     foreach ($criteria->getGroupByColumns() as $column) {
         $criteria->addSelectColumn($column);
     }
     $criteria->addJoin(NgTestApplicantPeer::NG_REG_INFO_ID, NgRegInfoPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::DEPARTMENT_ID, DepartmentPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::NG_REG_TEST_PERIOD_ID, NgRegTestPeriodPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::NG_STATUS_APPLICANT_ID, NgStatusApplicantPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::NG_APPLICANT_CATEGORY_ID, NgApplicantCategoryPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::COUNTRY_ID, CountryPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::RELIGION_ID, ReligionPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::REGION_ID, RegionPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::CITY_ID, CityPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::DISTRICT_ID, DistrictPeer::ID);
     $criteria->addJoin(NgTestApplicantPeer::SUBDISTRICT_ID, SubdistrictPeer::ID);
     $rs = NgTestApplicantPeer::doSelectRS($criteria, $con);
     if ($rs->next()) {
         return $rs->getInt(1);
     } else {
         return 0;
     }
 }