If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Problem of max(count(*))

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-02-03, 02:11
fairicky fairicky is offline
Registered User
 
Join Date: Oct 2003
Posts: 6
Problem of max(count(*))

Can someone tell me why the following sql statement cannot retrieve the
maximum count of the record:

SELECT col, max(count(*)) FROM table
GROUP BY col

And also, can I use one sql statement to retrieve the maximum count of the
record? If not, how?

Thank you more!!
Reply With Quote
  #2 (permalink)  
Old 10-02-03, 05:44
alligatorsql.com alligatorsql.com is offline
Registered User
 
Join Date: Jul 2001
Location: Germany
Posts: 189
Two group functions

Hello,

you use two group function MAX and COUNT in one statement, but there is only on group by function. So the error will be "no group ..."

The count is already the maximum in the group col, but if you need the
maximum of all col the use


SELECT max(count(*)) FROM table

Hope that helps

Manfred Peter
Alligator Company Software GmbH
http://www.alligatorsql.com
Reply With Quote
  #3 (permalink)  
Old 10-02-03, 06:27
itsmanyam itsmanyam is offline
Registered User
 
Join Date: May 2003
Posts: 45
Re: Problem of max(count(*))

i dont know what you exactly want to retrive using max(count(*))

actually count(*) will return only one value which is maximum.

so i think the following should work for u


SELECT col, count(*) FROM table
GROUP BY col
Reply With Quote
  #4 (permalink)  
Old 10-03-03, 02:36
evanhattem evanhattem is offline
Registered User
 
Join Date: Sep 2003
Location: The Netherlands
Posts: 311
hi,

the only way max(count()) will have any meaning, is by getting more then 1 row from count().....
Only that case the max function will have any relevance.

example:
select count(*) from emp return one row. This is always the max
select count(*), deptno from emp group by deptno will return 3 rows. Now I have a situation in which a max would have relevance.


Hope this helps
__________________
Edwin van Hattem
OCP DBA / System analyst
Reply With Quote
  #5 (permalink)  
Old 10-08-03, 04:12
georgemarousi georgemarousi is offline
Registered User
 
Join Date: Oct 2003
Posts: 3
Re: Problem of max(count(*))

SELECT max(count(*)) FROM table
GROUP BY col
/*that's all folks!*/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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