select *, count(URGdata.vstockno) as cc from (
SELECT *,enter_date as ladate,
(select imageurl from URG_images where stock = vstockno and imagetype = 'V' and urgid = yardid order by imgname limit 1) as imageurl
FROM urg_veh_data left join URGdata on urg_veh_data.vstockno = URGdata.vstockno
where
urgid in ('NJ25','NJ30','NJ31','NJ32')
and crush_date = '0000-00-00 00:00:00'
and enter_date > NOW() - INTERVAL 30 DAY
) xxx
where imageurl is not NULL
group by vstockno
order by enter_date desc limit 60