Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Unanswered: how to calucalte the number of count greater than 2

    The question i have two column

    Name || project name

    i want the list of name who has requested more than two project
    so i wrote

    select name ,count(name) from client group by name;
    but it only list of client and their count
    select name from client group by name where count(name)>2 ;
    i get an error please help me in redefining the error

  2. #2
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    illusiondinesh, Change the WHERE to HAVING in your second query.
    Code:
    SELECT name
    FROM client_group
    GROUP BY name
    HAVING count(*) > 1

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Stealth_DBA
    illusiondinesh, Change the WHERE to HAVING in your second query.
    Code:
    SELECT name
    FROM client_group
    GROUP BY name
    HAVING count(*) > 1
    stealth, it should be > 2, not > 1
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    Yes, you are correct. I completely missed the '...more than 2...' in the original post. I am so used to finding where something is there more than once, I must have typed on autopilot. Thanks for keeping illusiondinesh and me straight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •