I have a table which contains a book and then multiple prices about the book (this is a highly simplified sample):
ID BOOK PRICE 1 BOOK1 10 2 BOOK1 15 3 BOOK1 12 4 BOOK2 8 5 BOOK2 2
I am easily calculating the average, but there must be a nice way to calculate the median?
Current SQL:
SELECT DISTINCTROW Books.BOOK, Avg(Books.PRICE) AS [Avg Of PRICE] FROM Books GROUP BY Books.BOOK;
Results:
BOOK Avg Of PRICE BOOK1 12.3333333333333 BOOK2 5
There is no Median in Jet SQL, unless it has been added for 2007, but here is an idea of how to get one. You will need …
Some SQL …
And a User Defined Function (UDF).
From: LessThanDot Wiki