I am using SQL Server 2008.
1. The table of products above was created from data from another table.
PRODUCT_SORT is the result of sorting the PRODUCT and EVENT_ORDER together
2. Non Product records were inserted (lines in Yellow) from other sources
3. Table sorted by SERIALNO and DATE
**Problem:**
- In the table above, the products PROD_03 and PROD_04 are OK (green) and PROD_01 and PROD_02 are NOT OK (red)
- The two records of each product must be together and sorted as in the first table at the top
**The goal is:**
Due to registration, I found many mistakes, so I have to do some corrections to put it in order to make the analysis
**Brainstorming my ideas:**
- I've thinking on how to do some king of sorting
- Maybe to have a Product table and non product table. Create a loop and insert records from one and the other
**I am here just to ask for some approaches** on how to resolve these problems. That's it, **no code needed!**
**Result table**
- The two records of each product must be together and sorted as in the first table at the top.
- Non product records must be between two different products ordered by date.
Regards,
Elio Fernandes



Asked by Elio Fernandes
(169 rep)
Aug 26, 2022, 05:12 PM
Last activity: Aug 28, 2022, 06:58 PM
Last activity: Aug 28, 2022, 06:58 PM