Named query problem

Someone who finds this might find the following useful: