Turns out to be quite simple. You use the "PostgreSQL execute and Load" process step. And the output from this SQL will be available as inputs to other steps.
Also worth knowing that this does not work unless your query outputs a geometry (despite it being marked optional). I faked it with:-
SELECT distinct code,