Re: [Sqlalchemy-tickets] [sqlalchemy] #2796: Labeled subqueries
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-08-06 09:25:37
|
#2796: Labeled subqueries
----------------------------------+------------------------------------
Reporter: kvesteri | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone:
Component: sql | Severity: no triage selected yet
Resolution: | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Comment (by kvesteri):
As a follow up it would be nice to be able to use labeled unioned
subqueries, for example:
{{{#!python
import sqlalchemy as db
company_ids = db.select([Company.id], from_obj=Company.__table__)
user_ids = db.select([User.id], from_obj=User.__table__)
print db.session.execute(db.select([db.func.count(db.distinct('id'))],
from_obj=company_ids.union(user_ids).label('entity_ids'))).fetchall()
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2796#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|