I want to have Grand total of Count(*)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • inamul
    New Member
    • Sep 2007
    • 8

    I want to have Grand total of Count(*)

    I want to see how many people have registered from Countries and also want to Sum the total

    Table fields
    1. Name,
    2. Email
    3 Country

    I use this query to get number of people registered against country
    [CODE=mysql]
    SELECT count(*) as COUNT , country as COUNTRY
    FROM `epoc_vreg_inte rsec` group by country
    [/CODE]
    Code:
    COUNT 	COUNTRY
    1 	 
    1 	Azerbaijan
    1 	Bahrain
    1 	Canada
    1 	Germany
    5 	Iran
    1 	Japan
    2 	Jordan
    7 	Kuwait
    4 	Lebanon
    2 	Libyan Arab Jamahiriya
    2 	Oman
    1 	Pakistan
    2 	Qatar
    2 	Romania
    12 	Saudi Arabia
    1 	Syria
    2 	Thailand
    2 	Turkey
    60 	United Arab Emirates
    5 	United Kingdom
    Above query works but but i also want total of count field also using same query.
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Thanks for using CODE tags. But use it where it requires.

    Use WITH ROLLUP option
    [CODE=mysql]SELECT count(*) as COUNT, country as COUNTRY
    FROM `epoc_vreg_inte rsec` GROUP BY country WITH ROLLUP;[/CODE]

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Originally posted by mwasif
      Thanks for using CODE tags. But use it where it requires.

      Use WITH ROLLUP option
      [CODE=mysql]SELECT count(*) as COUNT, country as COUNTRY
      FROM `epoc_vreg_inte rsec` GROUP BY country WITH ROLLUP;[/CODE]
      [code=oracle]

      SELECT count(*) AS COUNT, SUM(COUNT(*)) OVER() FROM epoc_vreg_inter sec GROUP BY country

      [/code]

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        Originally posted by amitpatel66
        [code=oracle]

        SELECT count(*) AS COUNT, SUM(COUNT(*)) OVER() FROM epoc_vreg_inter sec GROUP BY country

        [/code]
        Hi amitpatel66,
        Is this a valid MySQL syntax?

        Comment

        Working...