select query - how can i do this

Original text of this message