Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL: Select Customer from Table1 who purchased material in table2 and find out what else did that customer purchase in the same month?
    primarykey
    data
    text
    <p>I have 2 tables that have a common column Material:</p> <p>Table1</p> <pre><code>MaterialGroup | Material | MaterialDescription | Revenue | Customer | Month MG1 | DEF | Desc1 | 12 | Customer A| Nov MG2 | ABC | Desc2 | 13 | Customer A| Nov MG3 | XYZ | Desc3 | 9 | Customer B| Dec MG3 | LMN | Desc3 | 9 | Customer B| Jan MG4 | IJK | Desc4 | 5 | Customer C| Jan </code></pre> <p>Table2</p> <pre><code>Vendor | VendorSubgroup| Material| Category KM1 | DPPF | ABC | Cat1 KM2 | DPPL | XYZ | Cat2 </code></pre> <p>There are two parts of the problem:</p> <p>Part1 is fairly straight forward</p> <p>I want to select all records from table1 where Material in table1 matches Material in table2</p> <p>In the above scenario, I would want this result because the Material "ABC" and "XYZ" are present in table2:</p> <pre><code>MG2| ABC| Desc2| 13 | Customer A| Nov MG3| XYZ| Desc3| 9 | Customer B| Dec </code></pre> <p>I used the following query to get the result and it worked:</p> <pre><code>SELECT T1.* FROM TABLE1 AS T1 INNER JOIN TABLE2 AS T2 ON T1.MATERIAL = T2.MATERIAL </code></pre> <p>Part 2 is a bit complicated and I need help for this now:</p> <p>After fetching all records from Table1 where material in table1 matches material in table2, I need to go to that Customer in table1 who purchased material from table2 and find out what else did that customer buy (which materials did he buy) in that same Month?</p> <p>So, in this example: I would want the following result-</p> <pre><code>MG1| DEF| Desc1| 12 | Customer A| Nov </code></pre> <p>because Customer A purchased Material from table2 - they also purchased some other material in the same month.</p> <p>Any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload