I don't know of any books, but there are many places online that gives you pointers.
My favorite is the Writer's Digest query letter series that shows you real query letters of published books and the author's literary agent critiques the query and tells what works about it.
http://www.writersdigest.com/editor-blogs/guide-to-literary-agents/successful-queries
My other favorite is query shark. She critiques queries people send her and you can apply her comments/critiques to your own query letter. I suggest you read the whole blog to get the gist of it.
http://queryshark.blogspot.com
& lastly, but not least, I also like the query letters at http://pubrants.blogspot.com Scroll the sidebar and you'll find her query series with the real query letters for her clients' books. She has also posted query letters in the past of people who sent her a query letter, but gave her permission to post it on her blog if there was something she wanted to bring to writer's attention. She doesn't do that anymore, but you can find the posts by searching her blog.
There's nothing wrong with writing a query letter before the novel is complete. I write a query letter and synopsis before I even start the novel. I use this as a way to get my plot written down because sometimes I do forget details of the plots and characters when I start writing, and it also gives me the opportunity to spot flaws in the plot before I start writing, and that means less time editing out those flaws if I correct them before I even start. And, since writing a great query can take as much effort as writing a novel, it's always great to start before the novel is complete. Another good thing about getting an early start on your query is that you won't bog your query down with unnecessary details that many writers do. for instance, when you first start your novel you'll have in mind the main plot and not all the small details and minor things that will go into your novel. So, at the beginning of writing your novel you query will mainly focus on what you already know - the main character, the antag, the stakes, and what happens if she fails. Those are the only thing that needs to be in your query. Many people who write the query after the novel will have so much information and think there's no way they can write a 1 page query with all the info they have. but the reality is they have a hard time extrapolating the important info from their novel because they want to add unnecessary details like subplots and sidekick stuff. So, you won't get bogged down by all that detail if you start before the novel is written or complete. And, if your novel changes while you're writing then you can easily change you query, so it's not like it's written in stone just because you wrote it before the novel was complete.
& I always like starting my query early because it takes a LONG time to get it perfect and once I finish and polish my novel then I don't want to spend another few months working the query synopsis.
Lastly, the best line of defense against a bad query letter is to get it critiqued by your writing peers.
Good luck with your query and novel!