Re: Distribution of records

From: Date: Tue, 21 Feb 2006 02:03:39 +0000
Subject: Re: Distribution of records
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-230779@lists.php.net to get a copy of this message
Hi Alan,
Formation OCall DCall OYards Key The key is an amalgam of the first 3 fields so a typical record might look like this:- Formation - I OCall - RT DCall - BZ OYards - 5 Key - IRTBZ What I want to do is to produce report that looks like this:- Form OCall DCall OYards - Median OYards - Mean OYards < 0 OYards 0 - 4 OYards 5+ So in other words for every combination of Formation, OCall and DCall I want to report how many times it occured, what the Median and Mean values were and what the distribution of plays was. I reckon I'm going to have to create an array and then loop over the array pulling out the relevant information but are there any special techniques I should consider?
You should be able to do this all in sql. Something like: select formation, count(formation) AS timesrun, ocall, dcall, AVG(oyards) FROM table GROUP BY formation, ocall, dcall;

« previous php.general (#230779) next »