Solved select for a general table