Re: [PHP-DB] Most Occurring

2001-02-22 Thread php3

Addressed to: Dale Frohman <[EMAIL PROTECTED]>
  [EMAIL PROTECTED]

** Reply to note from Dale Frohman <[EMAIL PROTECTED]> Thu, 22 Feb 2001 10:34:47 
-0500 (EST)
>
> Is there anyway with a mysql query to find which item in a particular
> field in a table occurs the most frequently?
>
> ie:
>
> table things
>
> field morethings
>
> item1
> item2
> item1
> item1
>
> I would like a query that runs and pulls whatever occurs the most.  In
> this case "item1"


Contrary to popular opinion, MySQL is quite powerful, and can do quite a
bit more than some seen to think around here.  Grumble, grumble.  You
can learn a lot from few hours reading the F* manual.


Try this:

   SELECT COUNT(*) AS Count, morethings
   FROM things
   GROUP BY morethings
   ORDER BY Count DESC
   LIMIT 1


Result

+---++
| Count | morethings |
+---++
| 3 | item1  |
+---++




Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: Re: [PHP-DB] Most Occurring

2001-02-22 Thread Allsebrook_Richard/askr
 BDY.RTF

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


Re: [PHP-DB] Most Occurring

2001-02-22 Thread Lennin Arriola

you mean the "mode".

I'm afraid you'll have to do it by hand. Other databases do have functions
for a couple of statistics measures( though not sure the mode is included),
but MYSQL doesn't.

Lennin Arriola
[EMAIL PROTECTED]





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Most Occurring

2001-02-22 Thread Dale Frohman

Is there anyway with a mysql query to find which item in a particular
field in a table occurs the most frequently?

ie:

table things

field morethings

item1
item2
item1
item1

I would like a query that runs and pulls whatever occurs the most.  In
this case "item1"

Thanks in advance



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]