select count(*) from(
select t.*, IFNULL(pr.reportery,0) reporteryQ
from (
SELECT
CONCAT('uploads/thumbnail/',ep.`picpath`,'/',ep.`newpicname`) picpath,
  CONCAT('uploads/image/',ep.`picpath`,'/',ep.`newpicname`) srcpath,
  b.`brandName`,c.`id`,c.`brand`,c.`brandId`,c.`partCode`,c.`partId`,c.`partName`,c.`pastureId`,c.`pastureName`,
TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM c.`price`))) price,
 c.`specification`,c.`unit`
FROM
    contract c
LEFT JOIN part_repertory pr  ON c.id = pr.contractId
LEFT JOIN warehouse w  ON  pr.locationId =w.id
LEFT JOIN brand b  ON b.id = c.brandId
LEFT JOIN bigcontract bc  ON bc.id = c.bigId
LEFT JOIN bigcontract bc2 ON bc2.contractCode = left(bc.contractCode,12)
join pasture_bigcontract pbt on pbt.bigcontract_id =bc2.id
LEFT JOIN parts ps  ON ps.id = c.partId
LEFT JOIN eq_pic ep  ON ep.id = ps.picpath
  WHERE 
bc.`providerId` = 1971 AND c.enable = 1
AND bc.`stopTime`>=DATE_FORMAT( NOW(),'%Y-%m-%d') 
and  bc.statue=1 and bc.SHStatus = 7 
AND if(''='' ,bc.SHStatus = 7,c.`partCode` ='' OR c.`partName` = '' OR c.`specification` ='')
and (bc.pastureId = 18 or  '' = 18 or  pbt.pasture_id = 18) 
)t 
left  join 
(
select reportery,contractId from part_repertory pr2 left join warehouse w  on pr2.locationId =w.id
where pr2.pastureId = 18 or (pr2.pastureId = 18 and  w.pastureId = 18)  limit 10
) pr  ON pr.`contractId` = t.`id` 
)a