Remove extra lines in test code. bugid:110910
Do not sort in aggregate function of SQL. bugid:110910