First question is why query? Lets see the advantage of queries.
1.First you can limit the amount of data you retrieve from the server by defining only the specific columns you need
2.You can join multiple tables into one query saving loop code pattern.
3.They are also light weight than Table Queries.
Below is the article which gives step wise procedure how to fetch data using a query and how to link it to a part page