Results 1 to 3 of 3
  1. #1
    RAJESHKUMAR R is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    48

    Union All For More Than Two Table!

    Dear Experts,

    In the Attached File, there is a Union Query Called as “For_Firm_UNION” which Right now pull the Data From FirmOrder & Forecast Table! Which is Working Fine!

    Now, I would like to add “SHIPMENT_FILTER” Query output also below Current Result of For_Firm_UNION Query! ie Product, Qty, CRD YrMo & Cat as “Shipment”

    Please suggest SQL Query which will give Desired Result!



    Code:
    SELECT Product, Qty, CRD, Format([CRD], "yyyy_mm") AS YrMo, "FO" AS Cat FROM Firmorder
    UNION ALL SELECT Product, Qty*-1, CRD, Format([CRD], "yyyy_mm"), "FC" FROM Forecast;
    
    


    Thanks & Regards,
    Rajeshkumar R
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    just add it to the end of the union, BUT it MUST have the exact # fields AND fieldTypes. (but not Names):

    SELECT Product, Qty, CRD, Format([CRD], "yyyy_mm") AS YrMo, "FO" AS Cat FROM Firmorder
    UNION
    SELECT Product, Qty*-1, CRD, Format([CRD], "yyyy_mm"), "FC" FROM Forecast
    union
    SELECT Product, Qty, CRD, Format([CRD], "yyyy_mm"), "XX" FROM [SHIPMENT_FILTER]

  3. #3
    RAJESHKUMAR R is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    48
    Dear Ranman,

    Thanks it works amazingly!

    Thanks & Regards,
    Rajeshkumar R

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

Similar Threads

  1. Replies: 4
    Last Post: 12-20-2015, 02:35 PM
  2. Union Query on one table
    By Wallatrix in forum Queries
    Replies: 1
    Last Post: 01-31-2013, 03:41 PM
  3. Table Union Question
    By Caulerpa in forum Queries
    Replies: 5
    Last Post: 01-14-2013, 03:02 PM
  4. how to update in a table union all query
    By learning_graccess in forum Queries
    Replies: 4
    Last Post: 03-31-2012, 07:32 AM
  5. Create table out of union query
    By DKruse1969 in forum Queries
    Replies: 2
    Last Post: 08-28-2009, 09:55 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