Restrictions in using Group By clause
1.The columns that appear in the Select list must be grouped and must appear in the GROUP By clause if a SELECT list contains any columns other than these in the aggregate functions.
2.No other column names can appear in the SELECT list and GROUP By must contain the column name on that the nested aggregate functions are performed if a SELECT list contains any nested aggregate functions.