Results 1 to 3 of 3
  1. #1
    becka11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    13

    Select Query with multiple counts and multiple criteria

    I have written a select query to give me the count of portfolio companies for a sector. However, I want to be able to return a count of portfolio companies by sector for multiple sectors. Here is my original query:



    SELECT Count(GainEvent_bySector.PortfolioCoName) AS CountofGainEventCET
    FROM GainEvent_bySector INNER JOIN PortfolioCompanies ON GainEvent_bySector.PortfolioCoName = PortfolioCompanies.PortfolioCoName
    WHERE (((GainEvent_bySector.Sector)="Communications and Enabling Technologies"))

    This gives me:
    CountofGainLossCET (one sector)
    21

    I want:
    CountofGainLossCET CountofGainLossCMA CountofGainLossDBA
    21 25 42

    Here is my structure:
    Click image for larger version. 

Name:	hitratebysector.PNG 
Views:	7 
Size:	4.3 KB 
ID:	11906

    Any assistance would be great!!!

  2. #2
    becka11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    13
    The spacing didn't come out, but the CountofX, CountofY, countofZ are the columns and The 21,25,42 are the rows below the corresponding columns

  3. #3
    becka11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    13
    Wow posting must have just given me good luck b/c I finally figured it out right after posting after spending a lot of time on it.

    Here is the final SQL:
    SELECT Count(GainEvent_bySector.PortfolioCoName) AS CountofGainEventSector, GainEvent_bySector.Sector
    FROM GainEvent_bySector INNER JOIN PortfolioCompanies ON GainEvent_bySector.PortfolioCoName = PortfolioCompanies.PortfolioCoName
    GROUP BY GainEvent_bySector.Sector;

    happy!

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

Similar Threads

  1. Replies: 7
    Last Post: 01-02-2013, 11:23 PM
  2. Replies: 1
    Last Post: 07-13-2011, 11:00 AM
  3. Multiple counts/sums needed
    By Audreysfirstdaughter in forum Queries
    Replies: 6
    Last Post: 05-25-2011, 02:14 PM
  4. Counts & Calcuations in Select Query
    By BLD21 in forum Queries
    Replies: 4
    Last Post: 04-08-2011, 11:29 AM
  5. Replies: 0
    Last Post: 02-28-2011, 09:46 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