SELECT @rownum := @rownum +1 AS rank,
round(LAT_N,4) as lat
FROM STATION
HAVING rank = CEIL(@rowCount/2)
ORDER BY LAT_N
我怎么能不显示排名?或者如何操作/分配变量以外的变量?
答案 0 :(得分:1)
使用子查询:
SELECT lat
FROM (SELECT @rownum := @rownum +1 AS rank,
round(LAT_N,4) as lat
FROM STATION CROSS JOIN
(SELECT @rownum := 0) params
ORDER BY lat_n
) s
WHERE rank = CEIL(@rowCount / 2) ;
请注意,在更新版本的MySQL中,您可能需要在子查询中进行排序。