Mainly, I want to order the ids in descending direction but also, how can I sort parent product/items (the ones with empty ean) first and their child rows below them?
Here's an example data from the database:
| id | ean | name |
| 1005 | 4064722314889 | Camera Protector Series 15T - Model: 15T - Qty: 2 |
| 1004 | 4064722314896 | Camera Protector Series 15T - Model: 15T Pro - Qty: 2 |
| 1003 | | Camera Protector Series 15T |
| 1002 | 4064722314162 | Smartwatch Case Series GT6 Pro - Color: Black - Size: 46 mm |
| 1001 | | Smartwatch Case Series GT6 Pro |
and so on...
Now, when I query it, I want to group it by id (desc) but also make sure to prioritize the row with an empty ean. Here's the desired result
| id | ean | name |
| 1003 | | Camera Protector Series 15T |
| 1005 | 4064722314889 | Camera Protector Series 15T - Model: 15T - Qty: 2 |
| 1004 | 4064722314896 | Camera Protector Series 15T - Model: 15T Pro - Qty: 2 |
| 1001 | | Smartwatch Case Series GT6 Pro |
| 1002 | 4064722314162 | Smartwatch Case Series GT6 Pro - Color: Black - Size: 46 mm |
and so on...
Thanks in advance!
ean, but only one of them is prioritized.