0
I have the following table of a mysql product movement database which contains the following fields:
id | prod_id | prod_name | movimento_tipo | data_transaction
1 | idProd1 | tv | ordemCompra | 1-jan-2018
2 | idProd1 | tv | shipped | 3-jan-2018
3 | idProd2 | pc | shipped | 4-jan-2018
4 | idProd2 | pc | ordemCompra | 5-jan-2018
5 | idProd3 | sapato | return | 8-jan-2018
6 | idProd3 | sapato | ordemCompra | 7-jan-2018
7 | idProd4 | camisa | ordemCompra | 10-jan-2018
8 | idProd4 | camisa | ordemCompra | 12-jan-2018
The tv product (idProd1) is correct. It had a purchase order on 1 jan and Shipping happened on 3 jan. The pc product (idProd2) has an error as Shipping came before (4-jan) than the purchase (5-jan). In the same way the shoe had a return before purchase. The shirt (idProd4 ) had 2 purchase orders but there was no return between these two purchases.
My question is what would be the sql query to capture each of these errors. I cannot use any language in the backend (php or python for example) to filter these situations.
what table holds the information that the product was delivered ?
– Jasar Orion
not precise. for this scenario, the important thing is only Shipping (when it was sent). But we could increase the granularity of the events. After all, a return could not be accepted without the product having been received. But since not all deliveries have signature and date of receipt, this field would be null for some cases.
– zwitterion