Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have two tables, an actuals and future table. In the query (query_actuals) below I select the activity for each property with the max report date. In the second query (query_future), I select all future activity for all properties. I was curious to see if it would be possible to combine the current months actuals with future as I have demonstrated in the below example (query_tbd). Any insight would be much appreciated. Thank you in advance!

    query_actuals (query that selects the max date)
    Property Year Month RoomNights RoomRevenue ReportDate
    1 2010 9 100 $1000.00 9/7/2010


    query_future (query that selects all future activity)
    Property Year Month RoomNights RoomRevenue ReportDate
    1 2010 9 20 $200.00 9/8/2010
    1 2010 10 5 $50.00 9/8/2010
    1 2010 11 10 $100.00 9/8/2010
    1 2010 12 15 $150.00 9/8/2010


    query_tbd
    Property Year Month RoomNights RoomRevenue
    1 2010 9 120 $1200.00
    1 2010 10 5 $50.00
    1 2010 11 10 $100.00
    1 2010 12 15 $150.00

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    You should be able to do that with a UNION query, i.e.
    Code:
    SELECT * FROM query_actuals UNION SELECT * FROM query_future
    Wendell

  3. #3
    Lounger
    Join Date
    Jun 2010
    Location
    Manchester, NH
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You will be able to do it with a UNION query but each Query will need to have the same number of columns. In your current situation, query_future has one more column than query_actuals. The Query should be something like this:

    SELECT Property, Year, Month, RoomNights, RoomRevenue
    FROM query_actuals
    UNION
    SELECT Property, Year, Month, RoomNights, RoomRevenue
    FROM query_future

    Hope that helps.

    Bob
    Bob Oxford
    Software Wizards, Inc.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Good point - I had missed the fact they were different.
    Wendell

  5. #5
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Worked like a charm! Thanks again!

Posting Permissions

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