[PHP-DB] MySQL query... count?

2004-03-01 Thread Tristan . Pretty
This problem pertains to a system that records all downloads from our 
site:

I have a field in my DB, that states which business unit owns the download 
that was recorded...
What I need to do for a new report, is say how many downloads were 
recorded for each Business unit?

I can select the Business units using Distinct, but hhow can I then count 
them?
I've tried:
SELECT DISTINCT(bu)buname, COUNT(buname)bucount FROM $table_name

But it doesn't work.. am I being dumb on this cold Monday morning?

Tris...


*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL query... count?

2004-03-01 Thread Jason Wong
On Monday 01 March 2004 18:53, [EMAIL PROTECTED] wrote:

 What I need to do for a new report, is say how many downloads were
 recorded for each Business unit?

 I can select the Business units using Distinct, but hhow can I then count
 them?
 I've tried:
 SELECT DISTINCT(bu)buname, COUNT(buname)bucount FROM $table_name

 But it doesn't work.. am I being dumb on this cold Monday morning?

Don't use DISTINCT, use GROUP BY.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
One thought driven home is better than three left on base.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL query... count?

2004-03-01 Thread Tristan . Pretty
Perfect...
I finally used..
SELECT DISTINCT(bu), COUNT(bu) FROM $table_name WHERE date BETWEEN 
'$date1' AND '$date2' group by bu

(I added the Distinct(bu) bit, to label the results correctly... god I 
love this list)

Have a great day!




Jason Wong [EMAIL PROTECTED] 
01/03/2004 11:03

To
[EMAIL PROTECTED]
cc

Subject
Re: [PHP-DB] MySQL query... count?






On Monday 01 March 2004 18:53, [EMAIL PROTECTED] wrote:

 What I need to do for a new report, is say how many downloads were
 recorded for each Business unit?

 I can select the Business units using Distinct, but hhow can I then 
count
 them?
 I've tried:
 SELECT DISTINCT(bu)buname, COUNT(buname)bucount FROM $table_name

 But it doesn't work.. am I being dumb on this cold Monday morning?

Don't use DISTINCT, use GROUP BY.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
One thought driven home is better than three left on base.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php