Hi I want delete this questiong in the forum.
Table emp1, id 3 the date (2013-05-226) is invalid.
Your query is sound - it does exactly as the requirements you described.
The problem seems to be your sample data or your expected result.
It's REALLY rude to overwrite the original question. Good luck with it.