Guest User

Untitled

a guest
Mar 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. SELECT property.paon, property.saon, property.street, property.postcode, property.lastSalePrice, property.lastTransferDate,
  2. epc.ADDRESS1, epc.POSTCODE, epc.TOTAL_FLOOR_AREA,
  3. (
  4. 3959 * acos (
  5. cos (radians(54.6921))
  6. * cos(radians(property.latitude))
  7. * cos(radians(property.longitude) - radians(-1.2175))
  8. + sin(radians(54.6921))
  9. * sin(radians(property.latitude))
  10. )
  11. ) AS distance
  12. FROM property
  13. RIGHT JOIN epc ON property.postcode = epc.POSTCODE AND CONCAT(property.paon, ', ', property.street) = epc.ADDRESS1
  14. WHERE property.paon IS NOT NULL AND epc.TOTAL_FLOOR_AREA > 0
  15. GROUP BY CONCAT(property.paon, ', ', property.street)
  16.  
  17. HAVING distance < 1.4
  18. ORDER BY property.lastTransferDate DESC
  19. LIMIT 10
Add Comment
Please, Sign In to add comment