Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    counting in a union query (2000-SR1)

    I have a union query based on 3 queries returning colors of tassels ordered. I need to count the number of each color tassel ordered. The SQL reads:
    SELECT [TasselColor] AS [Color]
    FROM [Tassel1]

    UNION ALL SELECT [TasselOnlyColor] AS [Color]
    FROM [Tassel3];

    UNION ALL SELECT [ExTasselColor] AS [Color]
    FROM [Tassel2];

    Is there a way to make this union query do the count of each color, or how do I do it? (The end result is of course of report reading something like:

    Black=3
    Red=2
    Gold=5

    etc.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: counting in a union query (2000-SR1)

    You can't do that in the union query itself, but you can create a totals query based on the union query. Add the Color field to the query grid twice, and set the Total option for the first column to Group By and for the second column to Count.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: counting in a union query (2000-SR1)

    Thanks, Hans! You really should do this for a living!
    Warren

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •