SELECT @rownum := @rownum +1 AS rank, round(LAT_N,4) as lat FROM STATION HAVING rank = CEIL(@rowCount/2) ORDER BY LAT_N
我怎么能不显示军衔呢?或者如何在select之外操纵/分配变量?
xzv2uavs1#
使用子查询:
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中,可能需要在子查询中进行排序。
1条答案
按热度按时间xzv2uavs1#
使用子查询:
请注意,在较新版本的mysql中,可能需要在子查询中进行排序。