I'm getting a little tired of all the jerkoffs who immediately jump in with comments like "You shouldn't be writing SQL code." Do you suppose anyone believes you were born with the ability to write perfect code? That's how people learn - try, make mistakes, try again, read, ask questions, post comments, listen to advice, tune your skills, swap ideas. If nobody did anything until they were perfect at it, nothing would ever get done, anywhere, by anybody.
Get over yourselves - you've made mistakes and written garbage code too, we all have. The trick is to learn from it, and if you're prepared for possible admission to the human race, help others learn as well.
Good manners are a nice plus, but if you can't post something that's at least helpful, go troll under someone else's bridge.
Anyone posting an article or script to be published for the entire community to benefit from (or to be nit picked incessantly) deserves to be treated with respect. Even if an author gets it quite wrong, if the follow-up discussion is professional and without personal attacks on a persons character or education then we can still learn something.
For anyone who thinks writing a submissible article or script is easy, I can say from experience that it's not. So to Sarvesh Singh I say keep trying and don't get discouraged!