Pankaj | #2033 | Moved queries to inner table and formatting