Correct my understanding. This query is selecting a lat_n value from the set such that there are an equal count of lat_n values that are lower than the selected value as there are lat_n values higher than the selected value. How would this work if the number of lat_n values are even? If the number of lat_n values were even, the median would not be a value in the set, it would be the mean of the 2 middle most values of the set.
it seems it is working by counting the rows where the number of rows > or < a number (which is median) get equal. but in case of even number of records, how will it work?
Correct my understanding. This query is selecting a lat_n value from the set such that there are an equal count of lat_n values that are lower than the selected value as there are lat_n values higher than the selected value. How would this work if the number of lat_n values are even? If the number of lat_n values were even, the median would not be a value in the set, it would be the mean of the 2 middle most values of the set.
it seems it is working by counting the rows where the number of rows > or < a number (which is median) get equal. but in case of even number of records, how will it work?
2 values i guess then?
Can this be considered efficient ? I am asking this because for every lat value, two selects will be run right ?
Hi brother can you explain me in detail why you wrote your query in that way
SELECT ROUND(median(LAT_N),4) AS median FROM STATION
Can you visualize the process of this code with smaller data sample? I can't visualize the subquery part.
Is it logically correct if there are even number of records?
Yes is will be logically correct.
NOt working in MYSQL
Its working, you just need to pay attention.