I think you should use sth like this:
In P2:
=INDEX('code list'!H$2:H$11,MATCH(1,('code list'!$E$2:$E$11=$V2)*('code list'!$G$2:$G$11>=query!$W2),0))
Confirmed by holding both Ctrl-Shift, then Enter.
Drag down and copy to Cost column