79262457

Date: 2024-12-08 12:39:08
Score: 0.5
Natty:
Report link

I am not sure if you really need DUAL, I think you can utilise the two tables ITEMS and ITEMS_RELATED and get the required output, let us know.

Fiddle

SELECT 
    CASE 
        WHEN ROW_NUMBER() OVER (PARTITION BY ir.MASTER_ITEM ORDER BY ir.RELATED_ITEM) = 1
        THEN ir.MASTER_ITEM
        ELSE NULL
    END AS ITEM_NUMBER,
    ir.RELATED_ITEM
FROM 
    ITEMS_RELATED ir
JOIN 
    ITEMS i
    ON ir.MASTER_ITEM = i.ITEM_NUMBER
ORDER BY 
    ir.MASTER_ITEM, ir.RELATED_ITEM;

Output

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: samhita