>  I.e., *all* columns from "th" are being added to the columns clause of
>  the select.   According to the SQL standard, these names all need to
>  be added to the GROUP BY as well - if MS-SQL is allowing only a
>  partial GROUP BY list, thats just poor behavior on the part of MS-SQL
>  (MySQL has this bug as well).  What this query really looks like is:
>
>  SELECT *, count(somecol) FROM table GROUP BY *
>
>  where the "*" includes the primary key column of the table, and
>  therefore it groups by the full set of columns on the table which
>  renders the count() meaningless.

so

a=session.query(th).filter(sqlalchemy.and_(th.APPLIED_TEST==1,th.CODING_DATE=='20080325')).group_by(th.RECORD_NO)._values(th.RECORD_NO,sqlalchemy.func.count(th.RECORD_NO)).all()

is just a slightly more complicated way of saying:

s=sqlalchemy.select([th.RECORD_NO,sqlalchemy.func.count(th.RECORD_NO)],sqlalchemy.and_(th.APPLIED_TEST==1,th.CODING_DATE=='20080404')).group_by(th.RECORD_NO).execute().fetchall()

If I had to pick I would just go with select. (unless there is other
reason to use query)

Is there a way to get this ?
SELECT RECORD_NO, count(RECORD_NO) FROM table GROUP BY RECORD_NO
(primary key is RECORD_ID)

The only way I know how to do it is via sqlalchemy.select
but I would like the query type of the return where my results are
 type(a) <type 'list'>
>>> type(a[0])
<class '__main__.th'>

How would I do that?
Lucas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to