Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2015

    Unanswered: How to JOIN tables to produce contiguous data

    I have a SQL database that has multiple tables I need to combine for an analytics presentation.
    The tables are PRODUCTS (contains product information and UPC), STORES (Store number, name and address), DATES (List of dates that data is published on), and DATA (quantity, by store, by UPC, by date). I am trying to combine these so that i have one table with a row for each UPC on each day at each store. Also, I would like to lookup values for year ago quantities at the same store for the same UPC. Is there a way to structure a query to provide all of this information? I know it will be a lot of rows, but I will filter by product prior to pulling the data.

    I think the solution requires a subquery in the FROM portion of the statement, but I am not sure how to structure it. Here are the Fields:
    Products.UPC, Data.UPC, Data.Store_Num, Stores.StoreNum, Data.StartDate, Dates.DateKey, and finally the reason we are here Data.Qty

    I am using an Azure SQL Database.

  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    Is it then end of the semester or the beginning?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jan 2007
    Provided Answers: 10
    What have you tried so far?

    Break your problem up in to separate little steps. Ignore the bit about data from a year ago to start with and focus on getting the core query correct first.
    Home | Blog

Posting Permissions

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