• I am really thankful to SSCrazy Eights and You (Ten Centuries). Your query is giving me the correct and required output. Its true that output can be easily get in higher version using Partition by clause, OVER() etc. analytic functions.

    Thank again so much.