On 11 Nov 2011, at 2:23am, dmp wrote:

> I'm getting the following exception:
> 
> SQLException: [SQLITE_ERROR] SQL error or missing database (near "ASC": 
> syntax error)
> 
> with:
> 
> SELECT name, color, Sum(price) AS price FROM key_table5 WHERE price > '2' 
> GROUP BY color ASC ORDER BY name ASC LIMIT 50 OFFSET 0
> 
> when either ASC or DESC is used with the GROUP BY clause.

Your query appears to be mixing simple results and aggregate results.  The 
point of GROUP BY
is to be able to do things like SUM().  But you have in your SELECT the 'name' 
column and there's no way to tell which name would be returned for any group.

Try this statement

SELECT color, Sum(price) AS sumPrice FROM key_table5 GROUP BY color

If that works, gradually add components of the query and figure out which one 
causes the problem.  I might, for example, expect uncertainty when you change 
it to

SELECT name, color, Sum(price) AS sumPrice FROM key_table5 GROUP BY color

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to