Results 1 to 6 of 6
  1. #1
    Eric2013 is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2013
    Posts
    14

    Sql count

    is there such a thing as SQL COUNT(DISTINCT column_name) or some form of this that would look at more then one column?

    been looking at w3schools and can't get what i'm looking for . Using access 2013. no sql servers.....yet...

    tks in advance. Eric


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    No sql counts what is in A column.
    Youd have to count all columns then sum across
    or
    make a crosstab to sum it.

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    well adding to R256's input; sort of depends on how one interprets your post... yes for sure there is a Distinct query. And distinct is the entire record which can be multiple columns/fields. But the fact that you can't find what you are looking for makes me think I am not interpreting your post correctly.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    eric,

    I agree with NTC re uncertain of your requirement. Can you post a few records and an example of what you want the query to return?

  5. #5
    Eric2013 is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2013
    Posts
    14
    this is what i've tried to use as well as a few combinations.

    I have a few columns of data with over 3000 work order ID's. What i'd like to be able to do, is for each unique part #, find out how many times each part # was used over a period of time over the entire table. EG: Part AF25555 might have been used a total of 23 times per 12 month rolling, but won't be in the same column or same work order ID.

    I've tried this knowing it's just asking per row and a sub total and it works, if i want to total the columns..:

    SELECT DISTINCTROW Sum([To Do List].[Other]) AS [Sum Of Other], Sum([To Do List].[Other 1]) AS [Sum Of Other 1], Sum([To Do List].[Other 2]) AS [Sum Of Other 2], Sum([To Do List].[Other 3]) AS [Sum Of Other 3], Sum([To Do List].[Other 4]) AS [Sum Of Other 4], Sum([To Do List].[Other 5]) AS [Sum Of Other 5]
    FROM [To Do List];

    but, i really want it to count how many times each part# was used.

    tks again in advance for any help.

    Eric

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    What is making this so difficult is that it sounds like you have a database design issue, specifically your data is not normalized. You should not have 6 different columns holding these part numbers like (Other, Other 1, ..., Other 6). Rather, you should just have two columns, the first which holds the index, and the second the part number.

    So instead of having something like 3000 records, each which 6 different fields for part numbers, you have should up to 18000 records, with exactly one part number in each record (in a single part number field). Then doing tasks like these is much easier.

    See here for tips on Database Design and Concepts of Normalization: https://support.office.com/en-us/art...rs=en-US&ad=US

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Count is returning the wrong count.
    By khughes46 in forum Reports
    Replies: 2
    Last Post: 05-26-2014, 12:46 PM
  2. Replies: 2
    Last Post: 04-15-2014, 01:59 PM
  3. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM
  4. Count if (where?)
    By jvlajcic in forum Queries
    Replies: 1
    Last Post: 12-14-2011, 03:09 PM
  5. Count on ID
    By dssrun in forum Access
    Replies: 4
    Last Post: 07-26-2011, 11:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums