Thanks Bastian it works, but i facing another problem while passing select
query object to pagination. Even i am filling *sqlalchemy_session *parameter
too. I am getting following exception

*TypeError: If you want to page an SQLAlchemy 'select' object then you have
to provide a 'sqlalchemy_session' argument. See also:
http://www.sqlalchemy.org/docs/04/session.html*

Thanks,
Santhosh


On Fri, Jun 5, 2009 at 1:37 AM, Bastian <bastian.b...@gmail.com> wrote:

>
> You supplied the join() as a the whereclouse (2nd) parameter to the
> select method.
>
> This should work:
> select([tags_table.c.name,tags_table.c.id, func.count
> (deal_tags_table.c.dealid).label('dealcount')],
> from_obj=join(tags_table,
> deal_tags_table),group_by=[deal_tags_table.c.dealid])
>
> Regards
>
> Bastian
>
> On 4 Jun., 11:43, "santhoshkumar.subram...@gmail.com"
> <santhoshkumar.subram...@gmail.com> wrote:
> > I have two tables "tags" and "deal_tag", and table definition follows,
> >
> > Table('tags', metadata,
> >            Column('id', types.Integer(), Sequence('tag_uid_seq'),
> > primary_key=True),
> >            Column('name', types.String()),
> >           )
> >
> > Table('deal_tag', metadata,
> >         Column('dealid', types.Integer(), ForeignKey('deals.id')),
> >         Column('tagid', types.Integer(), ForeignKey
> > ('tags.id')),
> >          )
> >
> > I want to select tag id, tag name and deal count (number of deals per
> > tag).
> >
> > I tried to create the query in sqlalchemy select function
> >
> > select([tags_table.c.name,tags_table.c.id, func.count
> > (deal_tags_table.c.dealid).label('dealcount')],join(tags_table,
> > deal_tags_table),group_by=[deal_tags_table.c.dealid])
> >
> > select function creates query linke this
> >
> > SELECT tags.name, tags.id, count(deal_tag.dealid) AS dealcount FROM
> > tags JOIN deal_tag ON tags.id = deal_tag.tagid WHERE tags JOIN
> > deal_tag ON tags.id = deal_tag.tagid GROUP BY deal_tag.dealid
> >
> > But my excepted query is
> >
> > SELECT tags.Name,tags.id,COUNT(deal_tag.dealid) FROM tags INNER JOIN
> > deal_tag ON tags.id = deal_tag.tagid GROUP BY deal_tag.tagid;
> >
> > Please help me
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to