select maxcount

Discussion in 'MySQL' started by divinequran, Oct 15, 2009.

  1. divinequran

    divinequran New Member

    Joined:
    Oct 9, 2008
    Messages:
    62
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Home Page:
    http://divinequran.com/
    Hi,

    How do i select max count of a table in a single query.

    Eg:
    Code:
    select type, count(*) as cc, [color=red]maxcount[/color] from t1 group by type;
    
    This is a example query i want the max row count to be printed in the same row. Is it possible?
     
    Last edited: Oct 15, 2009
  2. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    769
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    http://techiethakkar.blogspot.com
    what do you want in the max row count?

    Do you want the rowcount of the recordset returned after the group by?

    can you give an example?
     
  3. divinequran

    divinequran New Member

    Joined:
    Oct 9, 2008
    Messages:
    62
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Home Page:
    http://divinequran.com/
    I have a table with a categories like emp1, emp2, emp3 e.t.c.

    I want select the the max count of the category emp1 that is total now of rows of emp1. with where group=tempemp

    where i will use where clause..
     
  4. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    769
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    http://techiethakkar.blogspot.com
    what you want is just the count.
    There is no such things as max count

    count is just the count of records
    max is the maximum value of all the values in a particular column for a table

    If you are still referring to your original query, you need to modify it like this.
    select type, count(*) as cc from t1 group by type;
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice