WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-09-2004, 04:47 PM
4u 4u is offline
WebProWorld New Member
 

Join Date: Nov 2004
Posts: 3
4u RepRank 0
Default i need you help

in mysql how can i write "max(count(column_name))" in a query?
Reply With Quote
  #2 (permalink)  
Old 11-11-2004, 05:49 AM
WebProWorld New Member
 

Join Date: Oct 2004
Location: sb in us
Posts: 12
dr.p RepRank 0
Default

MySQL doesn't seem to like it when you use MAX(COUNT(column_name)) ... What I would normally do is, if I have a query like:

Code:
SELECT DISTINCT field_1, count(field_2) as f2_count FROM the_table
which returns ALL of the field_1 values with counts of field_2, then I would use:

Code:
SELECT DISTINCT field_1, count(field_2) as f2_count FROM the_table ORDER BY f2_count DESC LIMIT 1
to return only the highest. Hope that helps. Note that this should be the same thing:

Code:
SELECT field_1, count(field_2) as f2_count FROM the_table GROUP BY field_1 ORDER BY f2_count DESC LIMIT 1
__________________
"Oh Peter. You're what the Spaniards call El Terrible" ~ Cleveland of "Family Guy"
Reply With Quote
  #3 (permalink)  
Old 11-16-2004, 10:37 PM
godzilla's Avatar
WebProWorld Member
 

Join Date: Aug 2003
Location: Montreal, CA
Posts: 68
godzilla RepRank 0
Default Re: i need you help

Quote:
Originally Posted by 4u
in mysql how can i write "max(count(column_name))" in a query?
could you please give the full query? The problem is in the fact that count by itself may give a single value as result and thus the use of Max is illogical. Again, please supply the query.
__________________
Everything has its reason.
Your greatest glory doesn't consist in falling, but rising every time you fall and this is what defines a perfect human.
Godzilla's pass-time
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Tags:



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0