Results 1 to 4 of 4
  1. #1
    Prime_Directive is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    2

    Union All query help (SQL)

    Hi,



    I have two pivot queries I am trying to join into a single query. One shows attrition that happened for a total department and one shows attrition for a particular organization within the department. When I try to put a UNION ALL statement between the two queries I get an error that the "Transform" syntax is wrong. I suspect I am doing something incorrectly in how I have the aggregate functions laid out as this is the first time I have tried to combine two pivot queries. Can anybody please help? Thank you.

    -Andrew

    TRANSFORM Count(Terminations.[Standard Id])
    SELECT 'Org Attrition'
    FROM Terminations LEFT JOIN [Dept Taxonomy Mappings] ON Terminations.[Department Id]=[Dept Taxonomy Mappings].[Department ID]
    WHERE Terminations.[Specific Org] = "Yes"
    GROUP BY 'Org Attrition'
    PIVOT Terminations.[Loc City Name] in ("City 1","City 2","City 3")


    UNION ALL


    TRANSFORM Count(Terminations.[Standard Id])
    SELECT 'Total Attrition'
    FROM Terminations LEFT JOIN [Dept Taxonomy Mappings] ON Terminations.[Department Id]=[Dept Taxonomy Mappings].[Department ID]
    GROUP BY 'Total Attrition'
    PIVOT Terminations.[Loc City Name] in ("City 1","City 2","City 3");

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,952
    These are crosstab queries created with query builder?

    Try using alias field name in the crosstabs.

    TRANSFORM Count(Terminations.[Standard Id]) AS CountID

    Or save the crosstabs as query objects then build a UNION with those two objects.
    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
    Prime_Directive is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    2
    Thanks, I tried using alias fields and that didn't do the trick. How would I go about saving the crosstabs as query objects? Appreciate your help.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,952
    Just use the query builder - there is a wizard for crosstab. Save the query.
    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.

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

Similar Threads

  1. Union Query
    By guptaa13 in forum Access
    Replies: 4
    Last Post: 09-24-2014, 07:04 PM
  2. Union Query Help
    By bgwool in forum Queries
    Replies: 5
    Last Post: 07-17-2014, 12:34 PM
  3. Replies: 8
    Last Post: 10-22-2012, 07:43 PM
  4. Union Query
    By jlclark4 in forum Queries
    Replies: 3
    Last Post: 02-25-2011, 08:21 PM
  5. Union Query Help
    By jo15765 in forum Queries
    Replies: 7
    Last Post: 01-06-2011, 05:46 PM

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