SELECT `registrationid` as `schoolid`, `LName` as `schoolname`, `address`, `city`, `state`, `educationboard`, `profiletype`, `gender`, `schoolcategory`, `localityarea`, (select count(*) from tblreviews where tblreviews.sourceid = tblregistration.registrationid) as reviewcount, (select avg(rating) from tblreviews where tblreviews.sourceid = tblregistration.registrationid) as rating, (select count(*) from tblschoolaccount where tblschoolaccount.schoolid = RegistrationId) as isclaimed, (select objectid from tblcompareobject where tblcompareobject.objectid=tblregistration.RegistrationId AND isdelete = 0 AND tblcompareobject.usersession= '8q3vuasmn1qirkrgpgqapkhtnsh5l4mr' ) as cmpid, (select count(*) from tblcompareobject where tblcompareobject.objectid=tblregistration.RegistrationId) as comparecount, (select count(*) FROM `tblschoolviews` where tblschoolviews.schoolid = tblregistration.RegistrationId) as viewcount, (((ACOS(SIN(0 * PI() / 180) * SIN(latitude * PI() / 180) + COS(0 * PI() / 180) * COS(latitude * PI() / 180) * COS((0 - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515 * 1.609344)) as distance
FROM `tblregistration`
WHERE `city` = 'Pune'
HAVING `distance` <= 3
ORDER BY `distance` desc
LIMIT 10