Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Jun 2010
    Location
    Quincy, MA
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Nested SQL Query - Part 2

    Hi,

    Is it possible to take the below query and alter it (the UNION) such that instead of showing the aggregate amount of sub-queries "Qry_Aging_Subtotals_1_A" thru "Qry_Aging_Subtotals_1_F" it would show each of the values in the sub-queries?

    SELECT [Configuration Item Name], SUM(NumberOfActions)
    FROM (SELECT Qry_Aging_Subtotals_1.[Configuration Item Name], Sum(Qry_Aging_Subtotals_1.[CountOfConfiguration Item Name]) AS NumberofActions
    FROM Qry_Aging_Subtotals_1
    WHERE (((Qry_Aging_Subtotals_1.Expr1)=0))
    GROUP BY Qry_Aging_Subtotals_1.[Configuration Item Name]

    UNION
    SELECT * FROM [Qry_Aging_Subtotals_1_A]
    UNION
    SELECT * FROM [Qry_Aging_Subtotals_1_B]
    UNION
    SELECT * FROM [Qry_Aging_Subtotals_1_C]
    UNION
    SELECT * FROM [Qry_Aging_Subtotals_1_D]
    UNION
    SELECT * FROM [Qry_Aging_Subtotals_1_E]
    UNION
    SELECT * FROM [Qry_Aging_Subtotals_1_F]
    ) AS T
    GROUP BY [Configuration Item Name];

    An example being:

    A B C D E F

  2. #2
    Star Lounger
    Join Date
    Jun 2010
    Location
    Quincy, MA
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts
    The thread cut off, I'd be looking for something like

    widgets 63 97 84 28 18 36
    washers 158 279 202 50 26 22
    cables 52 129 128 29 23 46
    bolts 57 128 107 32 10 26

    Thanks,
    Thanos

Posting Permissions

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