Fred C wrote:
> On May 9, 2006, at 6:21 AM, Robert Szefler wrote:
>> Oleg Broytmann wrote:
>>> On Mon, May 08, 2006 at 01:03:53PM -0400, Fred C wrote:
>>>> I would like to execute a request with a GROUP BY and I understand
>>>> that can be done directly with SQLObject and has to be done using
>>>> SQLBuilder. But how ?
>>> connection.query(connection.sqrepr(Select("table", ["SUM(price)"],
>> Ouch - second parameter is expected to be the where clause, right?
>> My sepcific problem is:
>> SELECT COUNT(*) FROM table WHERE MONTH(dateAdded)=5 GROUP BY DAY
>> Now, how do you (wrestle to) express that in SQLObject?
> I did that and that works fine.
> conn = searchTags._connection
> sel = conn.sqlrepr(Select((func.COUNT('*'), searchTags.q.tag),
> tags = list(conn.queryAll(sel))
OK, already found the solution (the query is a bit more complicated):
I've had to change COUNT(*) to COUNT(id), though. func.COUNT('*') does
not work in general as it generates COUNT('*') in SQL. (Well, actually
it works by a leap of luck here, but relying on a hack is bad).
Any clue on how to get COUNT(*) itself?