Results 1 to 11 of 11

Thread: queries help

  1. #1
    Join Date
    Dec 2004
    Posts
    37

    queries help

    Hi, I was wondering when i use the count function why instead of 21 i would get 210 etc?

    Thanks.
    Last edited by 182; 01-09-2005 at 06:36 PM.

  2. #2
    Join Date
    Mar 2003
    Posts
    468
    count returns the number of rows in your query.

    maybe, supply the query here

  3. #3
    Join Date
    Dec 2004
    Posts
    37
    I don't have the query with me now but it is similar to:

    select employeeNo, name, count(project.project#) "over 20 projects"
    from employee, project
    where employee.employeeNo=project.employeeNo
    group by employeeNo, name
    having count(project.project#)>20


    The problem seems to happen for all the projets that have been counted.

  4. #4
    Join Date
    Mar 2003
    Posts
    468
    yup,
    you are counting the number of rows that satisfy the WHERE condition.

  5. #5
    Join Date
    Dec 2004
    Posts
    37
    So then why is it adding the extra zero to the numbers?

  6. #6
    Join Date
    Mar 2003
    Posts
    468
    no adding of zero.
    you have 210 rows that match the criteria of the where clause.

  7. #7
    Join Date
    Dec 2004
    Posts
    37
    Something else must be wrong then because I shouldn't have that it should be 21.

    Thanks for the help though.
    Last edited by 182; 01-09-2005 at 08:05 PM.

  8. #8
    Join Date
    Mar 2003
    Posts
    468
    issue the query without the COUNT function, the GROUP BY clause, and the HAVING clause.

    then tell me how many rows you get.

    if you need me to give you an example of what is happening, just say so

  9. #9
    Join Date
    Dec 2004
    Posts
    37
    Ok I will give it a go and see where I am going wrong thanks for the advice

  10. #10
    Join Date
    Jan 2005
    Posts
    4
    May be you should look at SELECT COUNT(DISTINCT fieldName) FROM tableName WHERE optionalClause;

  11. #11
    Join Date
    Feb 2003
    Posts
    1,048
    Or maybe post your actual query.

Posting Permissions

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