--- paiva...@gmail.com wrote:
From: Pavel Ivanov <paiva...@gmail.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] double calculation in SELECT Date: Mon, 5 Oct 2009 07:13:28 -0400 First of all, do you really store several rows with the same id in the table1? If no then you don't need 'group by' clause, if yes then I hope you understand that 'power' returned in your query is undefined, i.e. it can be returned from any row with this id - you can't control which one of them. And about the query: without some information about data stored in your tables and its structure we cannot give you a useful help. For example solution suggested by Edzard assumes that table1 has unique pairs id-power, otherwise it will return different results from your original query... Pavel ---------------------------------------------- Hello Pavel, No, I did not assume unique pairs of id, power. Actually there is a small syntax error in the original query, which is however tolerated by SQLite. The original query essentially (with respect to this point) looks like: SELECT id, power, .. FROM table1 GROUP BY id The column power is neither in the GROUP BY clause nor in an aggregate function. I assume SQLite returns just a single row per id here, also if there are more rows with the same id and different power. Other DBMS's do not accept this syntax and require to explicitly group by all columns that occur outside of aggregate functions. SQLite is more tolerant. Possibly that makes the unique sort faster. Edzard _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users