I built this SQL to determine a median salary (of which I was quite proud!):
Code: Select all
(SELECT Last(Salary) AS Middles
FROM (SELECT TOP 50 PERCENT Salary FROM tblExcel ORDER BY Salary ASC)
ORDER BY Last(Salary)) UNION ALL (SELECT Last(Salary) AS Middles
FROM (SELECT TOP 50 PERCENT Salary FROM tblExcel ORDER BY Salary DESC)
ORDER BY Last(Salary) );
Andy.
P.S. I'm aware that Access will return duplicate values (i.e. more than 50%) but this shouldn't matter in terms of a median value.