Results 1 to 3 of 3
  1. #1
    sathishkm21 is offline Novice
    Windows 10 Access 2007
    Join Date
    Jul 2017
    Posts
    6

    SQL Query

    Hi,

    I have a table consists of multiple company names.

    Company Name Count
    Advanced Micro Devices Inc 1
    Avnet Inc 5
    Avnet Inc 4
    Avnet Inc 3
    Avnet Inc 2
    Avnet Inc 1
    Capgemini Us Llc 2
    Capgemini Us Llc 1
    Cerner Corporation 1
    Colgate-Palmolive Company 1
    Compucom Systems Inc 1
    Computer Sciences Corporation 1
    Forsythe Solutions Group Inc 1
    Forsythe Technology, Inc. 1
    Hewlett-Packard Co 1
    Hitachi Data Systems Corporation 8
    Hitachi Data Systems Corporation 7
    Hitachi Data Systems Corporation 6
    Hitachi Data Systems Corporation 5
    Hitachi Data Systems Corporation 4
    Hitachi Data Systems Corporation 3
    Hitachi Data Systems Corporation 2
    Hitachi Data Systems Corporation 1


    Need SQL query to get all the company having count less than 3

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    select co, count from table where count < 3

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Try

    Code:
    SELECT COUNT([Company Name]), [Company Name]
    FROM YourTableNameHERE
    GROUP BY [Company Name]
    HAVING COUNT([Company Name]) <3
    ORDER BY COUNT([Company Name]);

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

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