esto soluciona tu problema:
Código SQL:
Ver originalCREATE TABLE #temp
(
cod_fae VARCHAR(20),
cod_esp VARCHAR(20),
can_rec INT
)
INSERT INTO #temp VALUES ('F01','S03',120)
INSERT INTO #temp VALUES ('F01','S05',300)
INSERT INTO #temp VALUES ('F02','S01',50)
INSERT INTO #temp VALUES ('F02','S04',30)
INSERT INTO #temp VALUES ('F03','S02',100)
INSERT INTO #temp VALUES ('F03','S07',170)
CREATE TABLE #temp2
(
cod_esp VARCHAR(20),
nom_esp VARCHAR(20)
)
INSERT INTO #temp2 VALUES ('S01','ATUN')
INSERT INTO #temp2 VALUES ('s02','corvina')
INSERT INTO #temp2 VALUES ('s03','ballena azul')
INSERT INTO #temp2 VALUES ('s04','pez espada')
INSERT INTO #temp2 VALUES ('s05','anchoveta')
INSERT INTO #temp2 VALUES ('s06','bacalao')
INSERT INTO #temp2 VALUES ('s07','ballena')
SELECT * FROM(
SELECT * FROM(
SELECT DISTINCT cod_fae FROM #temp
) AS t1,#temp2
) AS t3
WHERE cod_fae + cod_esp NOT IN(
SELECT t1.cod_fae + t2.cod_esp FROM #temp AS t1
LEFT JOIN #temp2 AS t2 ON (t1.cod_esp=t2.cod_esp)
)
si me preguntas porque uso #temp entonces si estamos en el hoyo ;)