Union Query with Count Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • greeni91
    New Member
    • Nov 2009
    • 61

    #1

    Union Query with Count Function

    Hi,

    I am currently trying to create a report that list all the Features that have been checked and the metrology used to check said feature.

    I have created a UNION query that will combine the fields used in my form into one column in a query. The problem I face is that if there are any duplicates in my UNION query they are combined but I do not know how many times that combination has appeared.

    I am needing a Count function added to my query that will tell me how many times the combination of Feature and Metrology have been used.

    Here is a copy of my SQL statement below. I have followed a few guides on the internet for this topic but cannot get the results I need.

    Any help is greatly appreciated.

    Code:
    SELECT [Feature 1] AS Feature, 
                 [Metrology Used 1] AS Metrology
    FROM tblFirstOff
    UNION
    SELECT [Feature 2],
                 [Metrology Used 2]
    FROM tblFirstOff
    UNION SELECT [Feature 3],
                 [Metrology Used 3]
    FROM tblFirstOff;
    Regards,

    Greeni91
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use union all. That preserves duplicates.

    Comment

    Working...