I exptected to find an aggregated function, like AVG, for calculating
median. But I didn't find such a function.
Anyone have a good solution of how to calculate median?
/Per-Olof
SELECT AVG(SeqCol)
FROM (
SELECT MAX(SeqCol)
FROM (
SELECT TOP 50 PERCENT SeqCol
FROM yourTable
ORDER BY SeqCol ASC
) AS _D1(SeqCol)
UNION ALL
SELECT MIN(SeqCol)
FROM (
SELECT TOP 50 PERCENT SeqCol
FROM yourTable
ORDER BY SeqCol DESC
) AS _D2(SeqCol)
) AS _Derived(SeqCol)
--
- Anith
--
Dejan Sarka, SQL Server MVP
FAQ from Neil & others at: http://www.sqlserverfaq.com
Please reply only to the newsgroups.
PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"Per-Olof Nilsson" <per-olof...@inxl.se> wrote in message
news:OuuCKnPdCHA.1688@tkmsftngp09...