Re: calculating a median within a query
- From: MGFoster <me@xxxxxxxxxxx>
- Date: Fri, 07 Jul 2006 20:00:42 GMT
jonm4102 wrote:
I'm trying to calculate the median of some numerical data. The data can
only be found in a query (henceforth query 1) field I previously made,
and I would prefer to calculate the median in a new query it without
making a table out of query 1. I can't find a median function in the
"Total" field, so is there so way to make an expression to calculate
the median of the orignial data from query 1 in my new query?
Also, what does name by string mean?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I've never seen the expression "name by string."
Here is a median finding query that I found on the web. It is set up
for T-SQL, but can be used in Access SQL; just change the names of the
tables/columns.
- -- From: http://www.aspfaq.com/show.asp?id=2506
- -- Find the median value
- -- For odd Count(*)
SELECT TOP 1 splunge FROM
(
SELECT TOP 50 PERCENT splunge
FROM blat ORDER BY splunge
) sub
ORDER BY splunge DESC
- -- For even Count(*). Can be used for odd Count(*) also.
SELECT AVG(splunge) FROM
(
SELECT splunge FROM (
SELECT TOP 1 splunge = splunge * 1.0 FROM
(
SELECT TOP 50 PERCENT splunge
FROM blat ORDER BY splunge
) sub_a
ORDER BY 1 DESC
) sub_1
UNION ALL
SELECT splunge FROM (
SELECT TOP 1 splunge = splunge * 1.0 FROM
(
SELECT TOP 50 PERCENT splunge
FROM blat ORDER BY splunge DESC
) sub_b
ORDER BY 1
) sub_2
) median
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBRK69c4echKqOuFEgEQK17QCgqqpRlyjWPsDoyDV7KwOO5KI/oUAAoJLV
BH3e8tVeYy7JbacvZJMQfDG7
=cNR0
-----END PGP SIGNATURE-----
.
- References:
- calculating a median within a query
- From: jonm4102
- calculating a median within a query
- Prev by Date: Re: Excel to Access
- Next by Date: Re: Deleting a table in another MDB
- Previous by thread: calculating a median within a query
- Next by thread: Re: calculating a median within a query
- Index(es):
Relevant Pages
|