Попробуйте это:
CREATE TABLE #TABLEA
(
CODEPRODUCT INT NOT NULL
, DESCRIPTION VARCHAR (100) NOT NULL
);
INSERT INTO #TABLEA VALUES (1, 'ok') ;
INSERT INTO #TABLEA VALUES (2, 'yes');
CREATE TABLE #TABLEB
(
LEVEL_1 INT NOT NULL
, LEVEL_2 INT NOT NULL
, LEVEL_3 INT NOT NULL
, LEVEL_4 INT NOT NULL
);
INSERT INTO #TABLEB VALUES(1, 2, 23, 75) , (1, 2, 53, 85);
SELECT #TABLEB.LEVEL_1
, TA_L1.DESCRIPTION AS DESCRIPTION1
, #TABLEB.LEVEL_2
, TA_L2.DESCRIPTION AS DESCRIPTION2
, #TABLEB.LEVEL_3
, TA_L3.DESCRIPTION AS DESCRIPTION3
, #TABLEB.LEVEL_4
, TA_L4.DESCRIPTION AS DESCRIPTION4
FROM #TABLEB
LEFT JOIN #TABLEA TA_L1
ON #TABLEB.LEVEL_1 = TA_L1.CODEPRODUCT
LEFT JOIN #TABLEA TA_L2
ON #TABLEB.LEVEL_2 = TA_L2.CODEPRODUCT
LEFT JOIN #TABLEA TA_L3
ON #TABLEB.LEVEL_3 = TA_L3.CODEPRODUCT
LEFT JOIN #TABLEA TA_L4
ON #TABLEB.LEVEL_4 = TA_L4.CODEPRODUCT;
Результат:
LEVEL_1, DESCRIPTION1, LEVEL_2, DESCRIPTION2, LEVEL_3, DESCRIPTION3, LEVEL_4, DESCRIPTION4
1 ok 2 yes 23 NULL 75 NULL
1 ok 2 yes 53 NULL 85 NULL