« first day (3255 days earlier)      last day (1063 days later) » 

9:24 AM
Morning
 
 
1 hour later…
10:32 AM
set @rowindex := -1; /* 1) creates an index*/
/* 3) the outer query will select the average of the 2(for odd no. of values)/1(for even) values we found in the middle of the sorted array */
select round(avg(lat_n),4)
from
/* 2) the index will increment for each new value of lat_n it finds, and sort them by lat_n
*/
(select @rowindex:=@rowindex+1 as rowindex, lat_n
from station
order by lat_n) as l
where l.rowindex in (floor(@rowindex/2), ceil(@rowindex/2));
can someone please explain how this loops through the rows? to me it looks like it only find the first
 
10:43 AM
@Trajan did you try it in a loop?
 
no that my only code
 
this makes it give a rowindex value per row
select @rowindex:=@rowindex+1
so for each row it increases @rowindex
 
@Zulatin see i would have thought that this just took the original rowindex (0) and increased it to 1 and then stopped
@Zulatin how does it know why to increase the rows though?
 
11:13 AM
i just cant find anything online where this sort of thing is covered
 

« first day (3255 days earlier)      last day (1063 days later) »