RE: [PHP] MySQL query for average records per day OT

2004-09-16 Thread Jay Blanchard
[snip] mysql> desc dates; +--+-+--+-+-+---+ | Field| Type| Null | Key | Default | Extra | +--+-+--+-+-+---+ | the_date | date| YES | | NULL| | | number | int(11) | | | 0 | | +--

Re: [PHP] MySQL query for average records per day

2004-09-16 Thread John Holmes
From: "Greg Donald" <[EMAIL PROTECTED]> mysql> select the_date, count(number), avg(number) from dates group by the_date; ++---+-+ | the_date | count(number) | avg(number) | ++---+-+ | 2004-01-01 | 3 | 2.

Re: [PHP] MySQL query for average records per day

2004-09-16 Thread Jeff Oien
John Holmes wrote: From: "Greg Donald" <[EMAIL PROTECTED]> You can't get the average and a count in the same query Sure you can. mysql> select count(number), avg(number) from numbers; Depends how you interpret his request, I guess. I took it as a request for the count of records per day and then

Re: [PHP] MySQL query for average records per day

2004-09-16 Thread Greg Donald
On Thu, 16 Sep 2004 16:08:45 -0400, John Holmes <[EMAIL PROTECTED]> wrote: > Depends how you interpret his request, I guess. I took it as a request for > the count of records per day and then the average of those counts. > > So, if you had > > D1 > D1 > D1 > D1 > D2 > D2 > D3 > > The count would

Re: [PHP] MySQL query for average records per day

2004-09-16 Thread John Holmes
From: "Greg Donald" <[EMAIL PROTECTED]> You can't get the average and a count in the same query Sure you can. mysql> select count(number), avg(number) from numbers; Depends how you interpret his request, I guess. I took it as a request for the count of records per day and then the average of those

RE: [PHP] MySQL query for average records per day OT

2004-09-16 Thread Jay Blanchard
[snip] > You can't get the average and a count in the same query Sure you can. mysql> select count(number), avg(number) from numbers; +---+-+ | count(number) | avg(number) | +---+-+ |18 | 2.3889 | +---+-+ 1 r

Re: [PHP] MySQL query for average records per day

2004-09-16 Thread Greg Donald
On Thu, 16 Sep 2004 15:15:01 -0400, John Holmes <[EMAIL PROTECTED]> wrote: > You can't get the average and a count in the same query Sure you can. > desc numbers; ++-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | ++-+--+---

RE: [PHP] MySQL query for average records per day

2004-09-16 Thread Jay Blanchard
[snip] I have a database with a date field in this format 20041016 I'd like to count how many records were made on each day (except today) and average them. Can I do this in one query or will I need to do some more PHP stuff after I get some results? Thanks. Bare bones so far: $sql = "select dat

Re: [PHP] MySQL query for average records per day

2004-09-16 Thread John Holmes
From: "Jeff Oien" <[EMAIL PROTECTED]> I have a database with a date field in this format 20041016 I'd like to count how many records were made on each day (except today) and average them. Can I do this in one query or will I need to do some more PHP stuff after I get some results? Thanks. Bare b

RE: [PHP] MySQL query for average records per day

2004-09-16 Thread Gryffyn, Trevor
Select date1,count(date1) group by date1 where date1 <> '$today' That'll get you the count of how many records were done on each day (excluding today). I don't know what you're trying to average, but you can probably figure it out from there. -TG > -Original Message- > From: Jeff Oien [