First off for Middle Grade(ages 8-12): 20,000-40,000- BUT if your novel is geared toward say 12 year olds and you have a 13 or 14 year old protagonist then the book should be between 32,000-40,000 instead of the low 20k.
Now YA: 55,000-69,000 he says is a great range. I know there are many writers that pull out the Harry Potter card, stating that it was over this word count. Well yes, but the first book wasn't all that long and by the time the others came out Rowling made her publisher A LOT of money.
Here is the exception. Fantasy. I can just see you fantasy writers jumping for joy. Fantasy can be longer because it involves world-building etc. But not much longer-
Be careful because extremely long novels make an agent think that a writer does not know how to edit themselves. We wouldn't want that now would we?
Also, for YA try not to go lower than 47K...and yes WAKE was 32,000k but it was an exception.
You can try to be the exception, but if you follow these rules for your first novel-you give yourself a better shot at breaking into the business. Check out his post if you want more, but I'm pretty sure I summarized the gist of it.
Good luck fellow writers!