Results 1 to 3 of 3
  1. #1
    spiroom is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    2

    SQL noob question, grouping results.


    Hi, I have a simple table like this:

    3 fields:
    code of person | code of workcenter | code of office

    1 wc1 of1
    2 wc1 of2
    3 wc1 of2
    4 wc1 of3
    5 wc2 of1
    6 wc2 of1
    7 wc2 of2
    8 wc2 of2

    I need the SQL instructions to obtain the list of workcenters (two rows), the number of offices for each center and the number of persons for each,
    This will be the result:

    wc1 | 3 | 4
    wc2 | 2 | 4

    it may be easy, but I am unable to find the solution with a simple Select.
    Please help and suggestions!
    Thanks in advance!!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    No, won't be simple.

    Query1
    SELECT workcenter, Count(office) AS CountOffice FROM (SELECT DISTINCT workcenter, office FROM table) AS Q1 GROUP BY workcenter;

    Query2
    SELECT workcenter, Count(person) AS CountPerson FROM table GROUP BY workcenter;

    Query3
    join the first two
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    spiroom is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    2
    Thanks June7 !!!!

    I thought that could be done with a single statement, ... thank you sincerely .

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

Similar Threads

  1. Replies: 6
    Last Post: 10-09-2013, 02:08 PM
  2. Complete noob question
    By lithium630 in forum General Chat
    Replies: 3
    Last Post: 12-12-2012, 10:03 PM
  3. Please help noob question.
    By Deano in forum Forms
    Replies: 3
    Last Post: 01-24-2011, 12:33 PM
  4. Total Noob Question
    By skubeedoo in forum Access
    Replies: 18
    Last Post: 09-23-2010, 03:03 PM
  5. HELP NOOB! Easy question
    By SigmaBlu in forum Queries
    Replies: 1
    Last Post: 10-10-2009, 11:23 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