فعلا نتونستم منطق ساده شده تر از این براش پیدا کنم.
امتحانش کنید:
SELECT SELECT [Id]
,[Mesc]
,[Line]
,[Unit]
,[Discription]
,[HeaderId]
FROM report2 as r1
WHERE exists
(select * from report2 as r2
where r1.line = 'h'
and r2.line ='i'
and r2.Description LIKE '%pump%'
and r1.headerID=r2.headerID)
or exists
(select * from report2 as r3
wher r1.line='i'
and r3.line='h'
and r1.headerID=r3.headerid
and r3.Description LIKE '%pump%')
or description like '%pump%'
ORDER BY HeaderID, Line, unit;