sql >> Database >  >> RDS >> Mysql

Subquery elimineren voor gemiddelde numerieke waarde

select 
  name
from 
  (select 
    round((min(LATITUDE) + max(LATITUDE)) / 2) as LATITUDE,
    round((min(LONGITUDE) + max(LONGITUDE)) / 2) as LONGITUDE
   from STATION 
   where DISTRICT_ID = '110' 
     AND NAME LIKE 'Vancouver%') AS center
  inner join STATION s
where
  s.DISTRICT_ID = '110' 
  and s.NAME like 'Vancouver%'
  and s.LATITUDE between center.LATITUDE - 5 and center.LATITUDE + 5
  and s.LONGITUDE between center.LONGITUDE - 5 and center.LONGITUDE + 5


  1. MySQL - Vind MIN maar niet nul

  2. Hoe databases worden gebruikt in e-commerce

  3. Crystal Reports versus Microsoft SQL Server Reporting Services

  4. Is er een verschil tussen SQL Server Express (2012) en LocalDB?