Create a column alias for the aggregate and then reference the alias in the ORDER BY clause.
Select Account, SUM(Cost) AS account_sum
group by account
order by account_sum
Apart from Self Joins, Group by, having and order, anything else you can use aliases for?
Can you agreggate them? (i.e. select sum(a) as s_a, sum(b) as s_b, s_a+s_b as total)
You can alias the tableName and/or columnName. For example on table names, those illegal characters or really LONG table occurrance names can be aliased and used with references if needed:
" SELECT c.firstName, c.\"Last Name\", c.address, c.city, s.stateFull, c.postal, c.country FROM \"contacts by contactType_customer\" AS c JOIN stateLookup AS s ON c.\"state\" = s.stateAbbrev WHERE c.\"state\" = 'IA' AND c.contactActive = 1 ORDER BY c.postal, c.lastName, c.firstName "
And when using more than one table, it's helpful to alias the tables. You can use any valid values for the alias'