created method to generate query result in a table