On Tue, May 08, 2012 at 05:20:03AM -0700, Eduardo wrote:
> Hi,
> Is there any function in sqlalchemy that filters out duplicates?
> For example the following rows satisfy a query:
> 1. (john, 23 , lpgh )
> 2.(steve , 35 , dbr )
> 3. (john ,76, qwe)
> 4. (mark, 35, epz)
> I would like that my query results contain only one row with john (either 1
> or 3 which one is not important) or with 35 (either 2 or 4).
> I tried with distinct(col) but it could not do the work.
You could try DISTINCT ON in combination with a UNION... maybe. DISTINCT
ON is documented here:
http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.distinct
and I'm not sure which dialects support this, apart from PostgreSQL.
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sqlalchemy/-/xnt0Zo5tSPUJ.
> 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.
>
-Ryan
--
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.