1 Reply Latest reply: Sep 3, 2015 6:37 PM by Petter Skjolden RSS

    Select and generate DATA from different tables

    Sebastian Müller

      Hello everyone:),

       

      I haven't much experience in QV for now, but I'm try to get familiar with it (already knowing SQL)...

       

      But now I've a problem, where I'm not able to discover the solution.

      My Steps until now:

       

      I'm loading two tables from an Excel File (that works fine) with the following result:

       

      Sales_Shop:

      Shop

      Week

      Category_Nr

      Sales

       

      ShopWeekCategory_NrSales
      1492015105
      349201510
      4512015128

       

      So Shop 3 doesnt have any sales in Category 10 and Week 492015.

       

       

      Shop

      Ref

       

      ShopRef
      31
      ......

       

      So Table 2 has the following function: Every Shop will be assigned a Reference Shop (Ref). In this case the Ref for Shop 3 is Shop 1.

       

      Now I have tried to get a third table with sales for every shop. The following logic should be applied.

      If Shop X has sales in Category_Nr Y and Week Z than this Sales should be taken in the new table. If the Shop doesnt have real Sales, than the Sales from the Ref Shop should be taken into account. The Result should look like this:

       

      ShopWeekCategory_NrSales
      1492015105
      3492015105
      4512015128

       

      So the red marked 5 in the last table are the Sales from Shop 1, which will be assigend to Shop 3 for this Week and Category_Nr, because Shop 3 doesnt have any real sales (look at table 1).

       

      I have no idea to how to get this result, as I'm not so familiar with the syntax in QV:/

       

      Thanks for all your help or advice:)