Results 1 to 4 of 4

Thread: count different

  1. #1
    Join Date
    Sep 2005
    Posts
    313

    Unanswered: count different

    Hi,

    I have a question.
    Suppose there is a table:
    Vendor__________Code ......................
    A________________1
    A________________2

    Dcount("Code","table","Vendor = A") = 2

    It is fine.

    Vendor__________Code ......................
    A_______________1
    A_______________1
    A _______________2

    Dcount("Code","table","Vendor = A") = 3

    I want to count the different between the code, it should be 2.

    I don't want to create the query to group it and then count the query, because the values of the rest of the fields of the table may be different.

    Does any function for count different? Thanks.

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,420
    Provided Answers: 7
    Group Vender and Code then count then
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by accessman2
    I want to count the different between the code, it should be 2.
    Either you're using funny math or I'm unclear as to how you're making that calculation...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    If your BE is SQL Server there is a jolly nice DISTINCT qualifier for COUNT
    e.g.
    Code:
    SELECT Vendor, COUNT(DISTINCT Code) As NoOfDistinctCodes
    FROM table
    if it is access then you have to fudge (about what Myle said)
    Code:
    SELECT A.Vendor, COUNT(*) As NoOfDistinctCodes
    FROM (SELECT DISTINCT Vendor, Code FROM table) AS A
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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