Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Oleg Broytmann <phd@ph...> - 2007-01-25 20:27:03
|
On Thu, Jan 25, 2007 at 01:54:00PM -0600, Jim Steil wrote: > I'm trying to group my result set by more than 1 column. I'm doing so with > the following: > > from sqlobject.sqlbuilder import * > from model import CheckLog > > conn = CheckLog._connection > query = Select([CheckLog.q.account, CheckLog.q.subAccount, > CheckLog.q.accountName, func.Sum(CheckLog.q.amount)], > groupBy=[CheckLog.q.account, CheckLog.q.subAccount, CheckLog.q.accountName], > orderBy=CheckLog.q.account) x = conn.queryAll(conn.sqlrepr(query)) > > .which nets me this SQL: > > SELECT CheckLog.account, CheckLog.subAccount, CheckLog.accountName, > Sum(CheckLog.amount) FROM CheckLog GROUP BY (CheckLog.account, > CheckLog.subAccount, CheckLog.accountName) ORDER BY CheckLog.account > > MySQL pukes on this and gives me: > > 1241, 'Operand should contain 1 column(s)' > > If I remove the parentheses around the columns in the Group By clause, > everything works. Is there anything I can do to get SO to NOT put the > parens around that clause? These parens are put by SequenceConverter() from converters.py but, of course, you cannot just remove the parens - they are needed in other queries. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@... Programmers don't die, they just GOSUB without RETURN. |