Hi,
I have a table with contract numbers (Kontraktnr), Item numbers and product category (UNSSPC_kode). The UNSPSC hierarchy is based on four levels: 1. Segment, 2. Family, 3. Class and 4. Commodity.
I need to find the most frequent product category on the lowest level (commodity level), grouped by contract number. But if the result is two or more product categories with the same count, then I would like to get the most frequent product category on the next level which is Class level and so on.
In my example I have two most frequent product categories on contract number 4700000001. The categories: 42131601 and 42131501 returns 5. So the right product category for us would be the Class level 42131600, because there is 6 contract items with this code.
Is is possible to make a query to return the most frequent product category based on four columns? And could anyone help me with the query design?
Best regards
I have a table with contract numbers (Kontraktnr), Item numbers and product category (UNSSPC_kode). The UNSPSC hierarchy is based on four levels: 1. Segment, 2. Family, 3. Class and 4. Commodity.
I need to find the most frequent product category on the lowest level (commodity level), grouped by contract number. But if the result is two or more product categories with the same count, then I would like to get the most frequent product category on the next level which is Class level and so on.
In my example I have two most frequent product categories on contract number 4700000001. The categories: 42131601 and 42131501 returns 5. So the right product category for us would be the Class level 42131600, because there is 6 contract items with this code.
Is is possible to make a query to return the most frequent product category based on four columns? And could anyone help me with the query design?
Best regards