How to write a db_select query? How can I  write a query to do the following:

select cid, thread and paragraph_id(I have added this field to comment table) from comment table, and then sort them first based on the paragraph_id and  then based on thread. So for the comments that have the same paragraph_id they will be sorted by thread number.
You probably want to look on the db_select documentation. I strongly reccomend on this comment.