Fix ordering on an aggregate in MSSQL

Ensure that an order clause which contains aggregate functions does not get manipulated.
This should fix jruby/activerecord-jdbc-adapter#532
Test group by and aggregate functions in order clause

Order clauses should allow aggregate functions on queries with group and limit clauses.
Merge pull request #549 from iaddict/master

Fix ordering on an aggregate in MSSQL