On 22 October 2011 17:28, Pete <p...@mollysrevenge.com> wrote: > If I have a SELECT statement like: > > SELECT cola, colb, sum(tableb.colc * tableb.cold) AS Total FROM TableA GROUP > BY cola ORDER BY Total
What is tableb? > > ...I get an error, I think because of referring to Total in the ORDER BY > clause. Is it not possible to refer to column aliases anywhere within a > SELECT statement other than in the AS clause? If not, is there any other > way to achieve this without repeating the sum expression? sqlite> create table tst( id integer primary key, cola integer, colb integer, colc integer, cold integer ); sqlite> SELECT cola, colb, sum( colc * cold ) as total from tst group by cola order by total; works for me, so I don't think that the alias is your problem. > > Pete Regards, Simon _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users